GithubHelp home page GithubHelp logo

Comments (8)

lemire avatar lemire commented on May 20, 2024

I don’t see how you can use simdutf without runtime dispatching. The implementations are system specific.

How would that work? How does the aarch64 implementation/kernel kicks in if you do not detect it?

from simdutf.

TerrorJack avatar TerrorJack commented on May 20, 2024

Ah, I really mean using a regular pointer for runtime dispatching instead of using an atomic, sorry for the confusion.

from simdutf.

lemire avatar lemire commented on May 20, 2024

@TerrorJack We use an atomic to ensure thread safety. We are open to changing this code, but one needs to prove that thread safety is maintained.

Honestly, a C++ platform that does not support atomics does not seem like a serious platform. Are you sure it is not supported?

from simdutf.

TerrorJack avatar TerrorJack commented on May 20, 2024

We are open to changing this code, but one needs to prove that thread safety is maintained.

Platforms that do support atomic will continue to use it by default.

Honestly, a C++ platform that does not support atomics does not seem like a serious platform. Are you sure it is not supported?

I'm sure wasm32-wasi doesn't have threads or atomics at the moment. The bundled libc does not have pthread, and the bundled libc++ does not ship anything threading related. And it is a serious platform! (well, at least serious enough for me to get paid.)

from simdutf.

WojciechMula avatar WojciechMula commented on May 20, 2024

Daniel, since the standard allows std::hardware_concurrency to return 0, I wouldn't be worried about thread safety. ;)

I'd be happy if we end up with some macro definition that explicitly enables the use of bare pointers. However, by default we should assume <atomic> is there.

from simdutf.

WojciechMula avatar WojciechMula commented on May 20, 2024

@TerrorJack It would nicer if we ended up with the following code:

#ifdef SIMDUTF_HAS_ATOMIC
template <typename T>
using simdutf::atomic = std::atomic;
#else
template <typaneme T>
using simdutf::atomic = dummy::atomic;
#endif

Where dummy::atomic is a template providing the methods from std::atomic we actually use.

from simdutf.

TerrorJack avatar TerrorJack commented on May 20, 2024

@WojciechMula IMHO adding dummy::atomic logic would make the PR much more bloated. I'll let it sit for a bit longer to gather more opinions.

from simdutf.

WojciechMula avatar WojciechMula commented on May 20, 2024

@TerrorJack technically your solution is fine. However, there are too many ifdefs --- five. :) There should be exactly one place in the code where we use an ifdef. Please rethink your approach. It'd be fine if we introduce a new header file for atomics.

from simdutf.

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.