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

Use builtin intrinsics on intel #2450

Merged
merged 2 commits into from
Aug 11, 2021

Conversation

white238
Copy link
Contributor

I ran into a bit of a mystery when I updated to fmt 8.0.1.

I got the following build error on intel 18.0.2:

fmt/format-inl.h(1923): error: identifier "ctz" is undefined
    int t = ctz(n);
            ^

In file included from fmt/format.h(2825),
                 from fmt/fmt.hpp(14),

The mystery is that fmt 8.0.1 did compiled on intel 19.0.4 but I am just not sure why intel 19 worked without this fix.

I tested this fix on intel 18, 19, and 2021.

Here is a godbolt example that shows intel has __builtin_ctz but not __has_builtin:

https://godbolt.org/z/xKrcaas8n

Intel Compiler Differences
intel 18 seems to be broken on godbolt but I tested it on our cluster
intel 2021 does have __has_builtin

@@ -150,16 +150,16 @@ FMT_END_NAMESPACE

// __builtin_clz is broken in clang with Microsoft CodeGen:
// https://github.com/fmtlib/fmt/issues/519
#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER
#if (FMT_GCC_VERSION || FMT_ICC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM but could you move the ICC check after FMT_HAS_BUILTIN? Same below.

#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz) || FMT_ICC_VERSION) && !FMT_MSC_VER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@vitaut vitaut merged commit 7b66e72 into fmtlib:master Aug 11, 2021
@vitaut
Copy link
Contributor

vitaut commented Aug 11, 2021

Thank you

sthagen added a commit to sthagen/fmtlib-fmt that referenced this pull request Aug 12, 2021
Use builtin intrinsics on intel (fmtlib#2450)
PoetaKodu pushed a commit to pacc-repo/fmt that referenced this pull request Nov 11, 2021
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.

2 participants