Skip to content

Conversation

@jorgensd
Copy link
Member

@jorgensd jorgensd commented Jan 5, 2026

Resolves #4010

@jorgensd jorgensd requested a review from garth-wells January 5, 2026 12:10
@jorgensd jorgensd added the housekeeping Tidying and style improvements label Jan 5, 2026
for (std::int32_t e : entities)
{
// Get first attached cell
if (num_entities_local <= e)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (num_entities_local <= e)
if (num_entities_local <= e) [[unlikely]]

Maybe good to add here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it will yield an optimization here, as there is no else-case, and there is no performance critical operation happening within the if test.

At least I get the same machine code for both GCC and clang with:

#include<vector>
#include<cstdint>
#include<stdexcept>

int test (std::int32_t max_size)
{
    std::vector<std::int32_t> a;
    for (auto ai: a)
    {
    if (ai >=max_size) [[likely]]
    // if (ai >=max_size) [[unlikely]]
    {
        throw std::runtime_error("error");
    }
    auto z = ai + 1;
    }
    return 0;

}

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

Labels

housekeeping Tidying and style improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: locate_dofs_topological segmentation (core dumped)

3 participants