Skip to content

Conversation

@ryan-berger
Copy link

No description provided.

- uses: actions/checkout@v4
- run: rustup toolchain install $RUST_VERSION --profile minimal
- run: |
rustup toolchain add nightly-2025-10-20 --profile minimal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have a rust-toolchain.toml it's enough just to have rustup toolchain install --profile minimal here and it automatically gets the version from the file. And we don't need the stable toolchain either right?

#[expect(clippy::as_conversions, reason = "u32 -> usize is valid")]
let surfaces = cpu::multithreaded_kernel(
&elevations,
self.dem.max_los_as_points as usize,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually just do: usize::try_from(self.dem.max_los_as_points)? here and no need for the lint exception.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, can do that


let (sin, cos) = (f64::sin(angle.to_radians()), f64::cos(angle.to_radians()));

#[expect(clippy::integer_division, reason = "we don't need precision here")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe .div_euclid(2)s?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me think about this a bit harder, euclid division may actually be the correct behavior for this one

clippy::integer_division,
reason = "i32 is constructed from (i32, i32) converting back should succeed"
)]
let x = (val / width as i32) - max_los as i32;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if some of these as conversions can just be i32::from(...) or i32::try_from(...)??

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try it out, but there are some weird issues regarding isize and i32s stopping a from. try_from is a perf penalty due to a panic if the value is out of bounds.

Let me double check on why I can't just do from

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usize/isize may be 64 bits, so there would be truncation so no on from. Still agree that try_from is a perf hit. If we could make it debug only, I'd welcome it.

@@ -0,0 +1,3 @@
[toolchain]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have a comment about what features we need from this channel and version. And maybe a Github issue to watch so we know when it reaches stable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Portable simd is what will be keeping us on nightly, and I don't know if they ever will stabilize it. I wouldn't count on it for another few years likely

@tombh
Copy link
Collaborator

tombh commented Oct 21, 2025

The only issue I see with this at the moment is that it's currently running your CPU implementation and then my old CPU implementation right afterwards! Ideally I think you should just replace my implementation. But really that should mean that your implementation is producing viewsheds and hooked into the tests. So for now, what about if we just add a new backend like crate::config::Backend::CPUNext?

@ryan-berger
Copy link
Author

The only issue I see with this at the moment is that it's currently running your CPU implementation and then my old CPU implementation right afterwards! Ideally I think you should just replace my implementation. But really that should mean that your implementation is producing viewsheds and hooked into the tests. So for now, what about if we just add a new backend like crate::config::Backend::CPUNext?

I don't think it runs both one after another. Notice the early return inside of the if matches!.

We can definitely create a new backend though!

@tombh
Copy link
Collaborator

tombh commented Oct 22, 2025

Oh sorry, I missed the early return!

So something like this then:

match self.config.backend {
    crate::config::Backend::CPUNext => cpunext(),
    crate::config::Backend::CPU | crate::config::Backend::Vulkan => oldcode(),
    crate::config::Backend::Cuda => todo!(),
}

That should fix the E2E test too.

Then I would say, that if you wanted, you could merge it. But no rush.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants