Skip to content

Commit

Permalink
remove cl
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Nov 22, 2023
1 parent 2335735 commit ce3336d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 417 deletions.
67 changes: 1 addition & 66 deletions bem/benches/assembly_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bempp_bem::assembly::{assemble_batched, batched, cl_kernel, BoundaryOperator, PDEType};
use bempp_bem::assembly::{assemble_batched, batched, BoundaryOperator, PDEType};
use bempp_bem::function_space::SerialFunctionSpace;
use bempp_element::element::create_element;
use bempp_grid::shapes::regular_sphere;
Expand Down Expand Up @@ -116,71 +116,6 @@ pub fn assembly_parts_benchmark(c: &mut Criterion) {
group.finish();
}

pub fn cl_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("cl_assembly");
group.sample_size(20);

for i in 3..5 {
let grid = regular_sphere(i);
let element = create_element(
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
Continuity::Discontinuous,
);

let space = SerialFunctionSpace::new(&grid, &element);
let mut matrix = zero_matrix([space.dofmap().global_size(), space.dofmap().global_size()]);

/*
group.bench_function(
&format!(
"Assembly of singular terms of {}x{} matrix",
space.dofmap().global_size(),
space.dofmap().global_size()
),
|b| {
b.iter(|| {
batched::assemble_singular(
&mut matrix,
&laplace_3d::Laplace3dKernel::new(),
false,
false,
&space,
&space,
&colouring,
&colouring,
128,
)
})
},
);
*/
group.bench_function(
&format!(
"Bempp-cl style assembly of non-singular terms of {}x{} matrix",
space.dofmap().global_size(),
space.dofmap().global_size()
),
|b| {
b.iter(|| {
cl_kernel::assemble(
&mut matrix,
&laplace_3d::Laplace3dKernel::new(),
false,
false,
&space,
&space,
)
})
},
);
}
group.finish();
}

// criterion_group!(benches, full_assembly_benchmark, assembly_parts_benchmark);
criterion_group!(benches, assembly_parts_benchmark);
//criterion_group!(cl_benches, cl_benchmark);
criterion_main!(benches);
//criterion_main!(benches, cl_benches);
87 changes: 0 additions & 87 deletions bem/src/assembly.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod batched;
pub mod cl_kernel;
use crate::function_space::SerialFunctionSpace;
use bempp_kernel::laplace_3d;
use bempp_tools::arrays::Mat;
Expand Down Expand Up @@ -53,35 +52,6 @@ pub fn assemble_batched<'a>(
};
}

pub fn assemble_cl<'a>(
output: &mut Mat<f64>,
operator: BoundaryOperator,
pde: PDEType,
trial_space: &SerialFunctionSpace<'a>,
test_space: &SerialFunctionSpace<'a>,
) {
match pde {
PDEType::Laplace => match operator {
BoundaryOperator::SingleLayer => {
cl_kernel::assemble(
output,
&laplace_3d::Laplace3dKernel::new(),
false,
false,
trial_space,
test_space,
);
}
_ => {
panic!("Invalid operator");
}
},
_ => {
panic!("Invalid PDE");
}
};
}

#[cfg(test)]
mod test {
use crate::assembly::batched;
Expand Down Expand Up @@ -149,61 +119,4 @@ mod test {
}
}
}

#[test]
fn test_against_cl() {
let grid = regular_sphere(2);
let element = create_element(
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);
let colouring = space.compute_cell_colouring();

let mut matrix =
zero_matrix::<f64>([space.dofmap().global_size(), space.dofmap().global_size()]);
batched::assemble_nonsingular::<16, 16>(
&mut matrix,
&laplace_3d::Laplace3dKernel::new(),
false,
false,
&space,
&space,
&colouring,
&colouring,
128,
);
let mut matrix2 =
zero_matrix::<f64>([space.dofmap().global_size(), space.dofmap().global_size()]);
cl_kernel::assemble(
&mut matrix,
&Laplace3dKernel::new(),
false,
false,
&space,
&space,
);

for i in 0..5 {
for j in 0..5 {
println!(
"{} {}",
*matrix.get([i, j]).unwrap(),
*matrix2.get([i, j]).unwrap()
);
}
println!();
}
for i in 0..space.dofmap().global_size() {
for j in 0..space.dofmap().global_size() {
assert_relative_eq!(
*matrix.get([i, j]).unwrap(),
*matrix2.get([i, j]).unwrap(),
epsilon = 0.0001
);
}
}
}
}
Loading

0 comments on commit ce3336d

Please sign in to comment.