fix offset selection implementation to match the pim isa automatic code format for pim-simulator
This commit is contained in:
@@ -53,10 +53,7 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vvadd,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 2)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 2).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
@@ -67,7 +64,8 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>()).unwrap()[0],
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![
|
||||
10.0.into(),
|
||||
12.0.into(),
|
||||
@@ -86,17 +84,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -157,10 +160,7 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vvsub,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 2)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 2).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
@@ -171,7 +171,8 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>()).unwrap()[0],
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![
|
||||
(-8.0).into(),
|
||||
(-8.0).into(),
|
||||
@@ -190,17 +191,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -261,10 +267,7 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vvmul,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 2)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 2).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
@@ -275,7 +278,8 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>()).unwrap()[0],
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![
|
||||
(9.0).into(),
|
||||
(20.0).into(),
|
||||
@@ -294,17 +298,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -365,10 +374,7 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vvdmul,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 2)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 2).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
@@ -379,10 +385,9 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), size_of::<T>()).unwrap()[0],
|
||||
vec![
|
||||
(492.0).into(),
|
||||
],
|
||||
.load::<T>(16 * size_of::<F>(), size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![(492.0).into(),],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
@@ -391,17 +396,19 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(16 * size_of::<F>() + size_of::<T>(), 4 * size_of::<i32>())
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -462,10 +469,7 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vvmax,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 2)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 2).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
@@ -476,16 +480,17 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>()).unwrap()[0],
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![
|
||||
9.0.into(),
|
||||
10.0.into(),
|
||||
11.0.into(),
|
||||
12.0.into(),
|
||||
13.0.into(),
|
||||
14.0.into(),
|
||||
15.0.into(),
|
||||
16.0.into(),
|
||||
9.0.into(),
|
||||
10.0.into(),
|
||||
11.0.into(),
|
||||
12.0.into(),
|
||||
13.0.into(),
|
||||
14.0.into(),
|
||||
15.0.into(),
|
||||
16.0.into(),
|
||||
],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
@@ -495,17 +500,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -577,10 +587,9 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), size_of::<T>()).unwrap()[0],
|
||||
vec![
|
||||
7.5.into(),
|
||||
],
|
||||
.load::<T>(16 * size_of::<F>(), size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![7.5.into(),],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
@@ -589,17 +598,19 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(16 * size_of::<F>() + size_of::<T>(), 4 * size_of::<i32>())
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -656,10 +667,7 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vrelu,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 1)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 1).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
@@ -670,16 +678,17 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8*size_of::<T>()).unwrap()[0],
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![
|
||||
0.0.into(),
|
||||
2.0.into(),
|
||||
11.0.into(),
|
||||
0.0.into(),
|
||||
13.0.into(),
|
||||
0.0.into(),
|
||||
7.0.into(),
|
||||
0.0.into(),
|
||||
0.0.into(),
|
||||
2.0.into(),
|
||||
11.0.into(),
|
||||
0.0.into(),
|
||||
13.0.into(),
|
||||
0.0.into(),
|
||||
7.0.into(),
|
||||
0.0.into(),
|
||||
],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
@@ -689,17 +698,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8*size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -756,32 +770,32 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vtanh,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 1)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 1).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
executable.execute();
|
||||
|
||||
// Check result correct
|
||||
|
||||
|
||||
assert!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8*size_of::<T>()).unwrap()[0].iter().zip(
|
||||
vec![
|
||||
T::from(0.1).tanh(),
|
||||
T::from(0.2).tanh(),
|
||||
T::from(0.3).tanh(),
|
||||
T::from(0.4).tanh(),
|
||||
T::from(0.5).tanh(),
|
||||
T::from(0.6).tanh(),
|
||||
T::from(0.7).tanh(),
|
||||
T::from(0.8).tanh(),
|
||||
]).all(|(&a,b) : (&T, T)| {a-b < 0.001.into()}),
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0]
|
||||
.iter()
|
||||
.zip(vec![
|
||||
T::from(0.1).tanh(),
|
||||
T::from(0.2).tanh(),
|
||||
T::from(0.3).tanh(),
|
||||
T::from(0.4).tanh(),
|
||||
T::from(0.5).tanh(),
|
||||
T::from(0.6).tanh(),
|
||||
T::from(0.7).tanh(),
|
||||
T::from(0.8).tanh(),
|
||||
])
|
||||
.all(|(&a, b): (&T, T)| { a - b < 0.001.into() }),
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
@@ -790,17 +804,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8*size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -815,7 +834,6 @@ fn vtanh_test() {
|
||||
vtanh_test_generic::<f64, f64>("vtanh<f64,f64>");
|
||||
}
|
||||
|
||||
|
||||
/// vsigm Test
|
||||
fn vsigm_test_generic<F, T>(err: &str)
|
||||
where
|
||||
@@ -858,32 +876,32 @@ where
|
||||
);
|
||||
inst_builder.make_inst(
|
||||
vsigm,
|
||||
idata_build
|
||||
.set_rdr1r2(3, 1, 1)
|
||||
.set_imm_len(8)
|
||||
.build(),
|
||||
idata_build.set_rdr1r2(3, 1, 1).set_imm_len(8).build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
let mut executable = Executable::new(cpu, core_instruction);
|
||||
executable.execute();
|
||||
|
||||
// Check result correct
|
||||
|
||||
|
||||
assert!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(16 * size_of::<F>(), 8*size_of::<T>()).unwrap()[0].iter().zip(
|
||||
vec![
|
||||
T::from(0.1).sigm(),
|
||||
T::from(0.2).sigm(),
|
||||
T::from(0.3).sigm(),
|
||||
T::from(0.4).sigm(),
|
||||
T::from(0.5).sigm(),
|
||||
T::from(0.6).sigm(),
|
||||
T::from(0.7).sigm(),
|
||||
T::from(0.8).sigm(),
|
||||
]).all(|(&a,b) : (&T, T)| {a-b < 0.001.into()}),
|
||||
.load::<T>(16 * size_of::<F>(), 8 * size_of::<T>())
|
||||
.unwrap()[0]
|
||||
.iter()
|
||||
.zip(vec![
|
||||
T::from(0.1).sigm(),
|
||||
T::from(0.2).sigm(),
|
||||
T::from(0.3).sigm(),
|
||||
T::from(0.4).sigm(),
|
||||
T::from(0.5).sigm(),
|
||||
T::from(0.6).sigm(),
|
||||
T::from(0.7).sigm(),
|
||||
T::from(0.8).sigm(),
|
||||
])
|
||||
.all(|(&a, b): (&T, T)| { a - b < 0.001.into() }),
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
@@ -892,17 +910,22 @@ where
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 16 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 16 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&buff,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
16 * size_of::<F>() + 8*size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
16 * size_of::<F>() + 8 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -917,10 +940,8 @@ fn vsigm_test() {
|
||||
vsigm_test_generic::<f64, f64>("vsigm<f64,f64>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// mvmul Test
|
||||
fn mvmul_test_generic<F,M, T>(err: &str, relu:i32)
|
||||
fn mvmul_test_generic<F, M, T>(err: &str, relu: i32)
|
||||
where
|
||||
F: From<f32> + std::fmt::Debug + PartialEq<F> + MemoryStorable,
|
||||
M: From<f32> + std::fmt::Debug + PartialEq<M> + MemoryStorable,
|
||||
@@ -948,12 +969,7 @@ where
|
||||
crossbar.execute_store(&matrix).unwrap();
|
||||
let mut cpu = pimcore::cpu::CPU::new(0, vec![vec![&crossbar]]);
|
||||
let (memory, _) = cpu.host().get_memory_crossbar();
|
||||
let vector: [F; _] = [
|
||||
1.0.into(),
|
||||
2.0.into(),
|
||||
3.0.into(),
|
||||
4.0.into(),
|
||||
];
|
||||
let vector: [F; _] = [1.0.into(), 2.0.into(), 3.0.into(), 4.0.into()];
|
||||
memory.execute_store(0, &vector).unwrap();
|
||||
|
||||
let mut inst_builder = InstructionsBuilder::new();
|
||||
@@ -974,7 +990,7 @@ where
|
||||
mvmul,
|
||||
idata_build
|
||||
.set_rdr1(3, 1)
|
||||
.set_mbiw_immrelu_immgroup(8*size_of::<M>() as i32, relu, 0)
|
||||
.set_mbiw_immrelu_immgroup(8 * size_of::<M>() as i32, relu, 0)
|
||||
.build(),
|
||||
);
|
||||
let core_instruction = vec![inst_builder.build().into()];
|
||||
@@ -982,54 +998,50 @@ where
|
||||
executable.execute();
|
||||
|
||||
// Check result correct
|
||||
if relu == 0 {
|
||||
assert_eq!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(4 * size_of::<F>(), 4*size_of::<T>()).unwrap()[0],
|
||||
vec![
|
||||
90.0.into(),
|
||||
(-24.0).into(),
|
||||
110.0.into(),
|
||||
120.0.into(),
|
||||
],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
}
|
||||
else {
|
||||
assert_eq!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(4 * size_of::<F>(), 4*size_of::<T>()).unwrap()[0],
|
||||
vec![
|
||||
90.0.into(),
|
||||
0.0.into(),
|
||||
110.0.into(),
|
||||
120.0.into(),
|
||||
],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
}
|
||||
if relu == 0 {
|
||||
assert_eq!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(4 * size_of::<F>(), 4 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![90.0.into(), (-24.0).into(), 110.0.into(), 120.0.into(),],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<T>(4 * size_of::<F>(), 4 * size_of::<T>())
|
||||
.unwrap()[0],
|
||||
vec![90.0.into(), 0.0.into(), 110.0.into(), 120.0.into(),],
|
||||
"Wrong result for {}",
|
||||
err
|
||||
);
|
||||
}
|
||||
// Check first part equal
|
||||
assert_eq!(
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<F>(0, 4 * size_of::<F>()).unwrap()[0],
|
||||
.load::<F>(0, 4 * size_of::<F>())
|
||||
.unwrap()[0],
|
||||
&vector,
|
||||
"Altered first part for {}",
|
||||
err
|
||||
);
|
||||
//Check that later is 0
|
||||
assert_eq!(
|
||||
executable.cpu_mut().host().load::<i32>(
|
||||
4 * size_of::<F>() + 4*size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
).unwrap()[0],
|
||||
executable
|
||||
.cpu_mut()
|
||||
.host()
|
||||
.load::<i32>(
|
||||
4 * size_of::<F>() + 4 * size_of::<T>(),
|
||||
4 * size_of::<i32>()
|
||||
)
|
||||
.unwrap()[0],
|
||||
[0, 0, 0, 0],
|
||||
"Altered first part for {}",
|
||||
err
|
||||
@@ -1038,22 +1050,21 @@ where
|
||||
|
||||
#[test]
|
||||
fn mvmul_test() {
|
||||
mvmul_test_generic::<f32,f32,f32>("mvmul<f32,f32,f32>",0);
|
||||
mvmul_test_generic::<f32,f32,f64>("mvmul<f32,f32,f64>",0);
|
||||
mvmul_test_generic::<f32,f64,f32>("mvmul<f32,f64,f32>",0);
|
||||
mvmul_test_generic::<f32,f64,f64>("mvmul<f32,f64,f64>",0);
|
||||
mvmul_test_generic::<f64,f32,f32>("mvmul<f64,f32,f32>",0);
|
||||
mvmul_test_generic::<f64,f32,f64>("mvmul<f64,f32,f64>",0);
|
||||
mvmul_test_generic::<f64,f64,f32>("mvmul<f64,f64,f32>",0);
|
||||
mvmul_test_generic::<f64,f64,f64>("mvmul<f64,f64,f64>",0);
|
||||
|
||||
mvmul_test_generic::<f32,f32,f32>("mvmul<f32,f32,f32>",1);
|
||||
mvmul_test_generic::<f32,f32,f64>("mvmul<f32,f32,f64>",1);
|
||||
mvmul_test_generic::<f32,f64,f32>("mvmul<f32,f64,f32>",1);
|
||||
mvmul_test_generic::<f32,f64,f64>("mvmul<f32,f64,f64>",1);
|
||||
mvmul_test_generic::<f64,f32,f32>("mvmul<f64,f32,f32>",1);
|
||||
mvmul_test_generic::<f64,f32,f64>("mvmul<f64,f32,f64>",1);
|
||||
mvmul_test_generic::<f64,f64,f32>("mvmul<f64,f64,f32>",1);
|
||||
mvmul_test_generic::<f64,f64,f64>("mvmul<f64,f64,f64>",1);
|
||||
mvmul_test_generic::<f32, f32, f32>("mvmul<f32,f32,f32>", 0);
|
||||
mvmul_test_generic::<f32, f32, f64>("mvmul<f32,f32,f64>", 0);
|
||||
mvmul_test_generic::<f32, f64, f32>("mvmul<f32,f64,f32>", 0);
|
||||
mvmul_test_generic::<f32, f64, f64>("mvmul<f32,f64,f64>", 0);
|
||||
mvmul_test_generic::<f64, f32, f32>("mvmul<f64,f32,f32>", 0);
|
||||
mvmul_test_generic::<f64, f32, f64>("mvmul<f64,f32,f64>", 0);
|
||||
mvmul_test_generic::<f64, f64, f32>("mvmul<f64,f64,f32>", 0);
|
||||
mvmul_test_generic::<f64, f64, f64>("mvmul<f64,f64,f64>", 0);
|
||||
|
||||
mvmul_test_generic::<f32, f32, f32>("mvmul<f32,f32,f32>", 1);
|
||||
mvmul_test_generic::<f32, f32, f64>("mvmul<f32,f32,f64>", 1);
|
||||
mvmul_test_generic::<f32, f64, f32>("mvmul<f32,f64,f32>", 1);
|
||||
mvmul_test_generic::<f32, f64, f64>("mvmul<f32,f64,f64>", 1);
|
||||
mvmul_test_generic::<f64, f32, f32>("mvmul<f64,f32,f32>", 1);
|
||||
mvmul_test_generic::<f64, f32, f64>("mvmul<f64,f32,f64>", 1);
|
||||
mvmul_test_generic::<f64, f64, f32>("mvmul<f64,f64,f32>", 1);
|
||||
mvmul_test_generic::<f64, f64, f64>("mvmul<f64,f64,f64>", 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user