things
This commit is contained in:
parent
a479181882
commit
7f285dbdec
@ -12,6 +12,7 @@ itertools = "0.10"
|
||||
rand = "0.8.3"
|
||||
rand_distr = "0.4"
|
||||
rayon = "1.5"
|
||||
fastapprox = "0.3.0"
|
||||
arrayfire = {git = "https://github.com/arrayfire/arrayfire-rust.git"}
|
||||
#arrayfire = "3.8.0"
|
||||
|
||||
|
||||
27
src/main.rs
27
src/main.rs
@ -5,10 +5,13 @@ use rand::Rng;
|
||||
use arrayfire as af;
|
||||
|
||||
fn main() {
|
||||
backend_man();
|
||||
// af::set_backend(af::Backend::CPU);
|
||||
af::set_device(0);
|
||||
af::info();
|
||||
let gpu_compute: bool = false;
|
||||
if gpu_compute {
|
||||
backend_man();
|
||||
// af::set_backend(af::Backend::CPU);
|
||||
af::set_device(0);
|
||||
af::info();
|
||||
}
|
||||
|
||||
// let n_iterations = 16384;
|
||||
let n_iterations = 2024;
|
||||
@ -39,11 +42,17 @@ fn main() {
|
||||
let mut model = model::Model::new(width, height, n_particles, n_populations, diffusivity);
|
||||
model.print_configurations();
|
||||
|
||||
// let dims = af::Dim4::new(&[n_particles as u64, 1, 1, 1]);
|
||||
for i in 0..n_iterations {
|
||||
model.step();
|
||||
// model.step_cl(dims);
|
||||
pb.set_position(i);
|
||||
if gpu_compute {
|
||||
let dims = af::Dim4::new(&[n_particles as u64, 1, 1, 1]);
|
||||
for i in 0..n_iterations {
|
||||
model.step_cl(dims);
|
||||
pb.set_position(i);
|
||||
}
|
||||
} else {
|
||||
for i in 0..n_iterations {
|
||||
model.step();
|
||||
pb.set_position(i);
|
||||
}
|
||||
}
|
||||
pb.finish();
|
||||
|
||||
|
||||
12
src/model.rs
12
src/model.rs
@ -188,16 +188,16 @@ impl Model {
|
||||
} = grid.config;
|
||||
let (width, height) = (grid.width, grid.height);
|
||||
|
||||
let xc = agent.x + agent.angle.cos() * sensor_distance;
|
||||
let yc = agent.y + agent.angle.sin() * sensor_distance;
|
||||
let xc = agent.x + fastapprox::faster::cos(agent.angle) * sensor_distance;
|
||||
let yc = agent.y + fastapprox::faster::sin(agent.angle) * sensor_distance;
|
||||
|
||||
let agent_add_sens = agent.angle + sensor_angle;
|
||||
let agent_sub_sens = agent.angle - sensor_angle;
|
||||
|
||||
let xl = agent.x + agent_sub_sens.cos() * sensor_distance;
|
||||
let yl = agent.y + agent_sub_sens.sin() * sensor_distance;
|
||||
let xr = agent.x + agent_add_sens.cos() * sensor_distance;
|
||||
let yr = agent.y + agent_add_sens.sin() * sensor_distance;
|
||||
let xl = agent.x + fastapprox::faster::cos(agent_sub_sens) * sensor_distance;
|
||||
let yl = agent.y + fastapprox::faster::sin(agent_sub_sens) * sensor_distance;
|
||||
let xr = agent.x + fastapprox::faster::cos(agent_add_sens) * sensor_distance;
|
||||
let yr = agent.y + fastapprox::faster::sin(agent_add_sens) * sensor_distance;
|
||||
|
||||
// Sense. We sense from the buffer because this is where we previously combined data
|
||||
// from all the grid.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user