Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit type cast to work around compiler error during build in Arch Linux's DKMS hook #12

Closed
wants to merge 1 commit into from

Conversation

marty1885
Copy link

Hi,

I know this is an unsupported setup. I'm working on a set of AUR packages to install Tenstorrent software onto Arch Linux. This patch fixes test building during Arch processing the DKMS hook during a kernel or driver upgrade. Otherwise the compiler complains about TENSTORRENT_MAX_DMA_BUFS being casted to 0 due to the 3rd parameter in AllocateDmaBuf is of type uint8_t but the value of TENSTORRENT_MAX_DMA_BUFS is 256.

@alewycky-tenstorrent alewycky-tenstorrent self-assigned this Mar 21, 2024
@alewycky-tenstorrent
Copy link
Contributor

alewycky-tenstorrent commented Mar 21, 2024

Which compiler are you using and is it with -Werror?

Does changing "if" to "if constexpr" also fix the error for you?

    if constexpr (TENSTORRENT_MAX_DMA_BUFS <= std::numeric_limits<decltype(tenstorrent_allocate_dma_buf_in::buf_index)>::max()) {
        auto buf_max = AllocateDmaBuf(dev_fd, page_size(), TENSTORRENT_MAX_DMA_BUFS);

If it does, I would prefer if constexpr rather than casting the value. That code path never runs unless TENSTORRENT_MAX_DMA_BUFS is representable in uint8_t anyway.

@marty1885 marty1885 closed this Apr 3, 2024
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.

None yet

2 participants