Giter Club home page Giter Club logo

Comments (3)

Convery avatar Convery commented on May 17, 2024

Example fix for line 470-483 as stolen from SO:

#ifdef PHMAP_HAVE_INTRINSIC_INT128
    inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high)
    {
        auto result = static_cast<unsigned __int128>(a) * static_cast<unsigned __int128>(b);
        *high = static_cast<uint64_t>(result >> 64);
        return static_cast<uint64_t>(result);
    }
#elif (defined(_MSC_VER))
    #if defined(_WIN64)
    #pragma intrinsic(_umul128)
    inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high)
    {
        return _umul128(a, b, high);
    }
    #else
    #pragma intrinsic(__emulu)
    inline uint64_t umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi)
    {
        uint64_t a = multiplier >> 32;
        uint64_t b = (uint32_t)multiplier; // & 0xFFFFFFFF;
        uint64_t c = multiplicand >> 32;
        uint64_t d = (uint32_t)multiplicand; // & 0xFFFFFFFF;

        uint64_t ad = __emulu(a, d);
        uint64_t bd = __emulu(b, d);

        uint64_t adbc = ad + __emulu(b, c);
        uint64_t adbc_carry = (adbc < ad); // ? 1 : 0;
        // MSVC gets confused by the ternary and makes worse code than using a boolean in an integer context for 1 : 0

        // multiplier * multiplicand = product_hi * 2^64 + product_lo
        uint64_t product_lo = bd + (adbc << 32);
        uint64_t product_lo_carry = (product_lo < bd); // ? 1 : 0;
        *product_hi = __emulu(a, c) + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry;

        return product_lo;
    }
    #endif
#endif

from parallel-hashmap.

greg7mdp avatar greg7mdp commented on May 17, 2024

Thanks for the report and suggesting a solution. Not closing the issue yet because there are a couple compilation warnings I need to take care of.

from parallel-hashmap.

greg7mdp avatar greg7mdp commented on May 17, 2024

I updated the code and checked on x86... works fine now. Thanks again for the bug report.

from parallel-hashmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.