GithubHelp home page GithubHelp logo

Threading about openrhythm HOT 14 OPEN

Salamandar avatar Salamandar commented on May 27, 2024
Threading

from openrhythm.

Comments (14)

mdsitton avatar mdsitton commented on May 27, 2024

I would rather not use OpenMP. It seems like it could be nice if you want to speed up stuff that is more sequential in nature. So I'm not sure it would be all that useful for us.

I think the traditional thread route would be better as long as we can reasonably figure a decent way to spread the workload around.

One idea is to look into implementing some form of thread pools. Basically we would setup a fixed number of threads based upon the number of cpu cores. The threads would always be running. Then we would queue up work to the threads. Certain things probably wont be able to be multithreaded, for example most windowing apis require you to only use the window from the thread you created it from for example. So we would probably need a few fixed threads, along with some threadpools to handle the other work.

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

However despite needing to do window/event stuff from the main thread. OpenGL should work from a thread that is separate from the main thread though i would need to experiment with that somewhat... I'm curious if that would allow us reduce input latency any :P

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

Though if we were going to go that route I would want to implement my own native Win32 and X11 windowing support. Because i think for X11 threading OpenGL is a bit more Finicky, I know its allowed on windows though.

from openrhythm.

Salamandar avatar Salamandar commented on May 27, 2024

I think you didnt understand one thing : I didnt mean it was one implementation or the other ;)
For instance I think that audio on-the-fly decoding could be speed up a (very little ?) bit with openMP. And SoundTouch uses (optionnal) OpenMP anyways ;)
I see what you mean about windowing, i've done enough GTK+ to know it ^^
Using thread pools could be a good idea, although we usually will have "fixed" tasks for the whole app lifetime. And I don't want some tasks to eventually block the app because we only have 2cores :p

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

Just as an update to this I did do that experiment with running opengl on a separate thread from the window event thread. It helps immensely with getting more accurate time stamps for input events, which i think will be very very useful when doing note hit detection.
So i really would like to transition everything to use this if possible, and move away for sdl2(it gives event timestamps but i just don't see them being as accurate as I want). The other option if a platform gives very accurate time stamps without needing to do a separate events thread then we wont need another thread for it(and if SDL2 uses the data the platform its running on for its internal timestamps then we can even use sdl2 for that platform as well).

from openrhythm.

Salamandar avatar Salamandar commented on May 27, 2024

That's a good thing then :D Even on Windows ?

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

Well the current thing is I know i can do it on windows, i'm not sure about linux or mac yet.

from openrhythm.

Salamandar avatar Salamandar commented on May 27, 2024

Well as I said in #17, we don't need to create a thread for the audio tasks, LibSoundio handles everything. Right now I don't think the code in soundio.cpp is multithread safe but I'll come around that. It's basically a non-issue right now.

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

The problem last I looked soundio is blocking unless you've changed its usage so it doesn't

from openrhythm.

Salamandar avatar Salamandar commented on May 27, 2024

It's not blocking "anymore". The only blocking function in libsoundio is wait_events and can be replaced by a regular call to flush_events. Its only purpose is to send the SoundIo::on_devices_change and SoundIo::on_backend_disconnect callbacks if needed.

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

Oh alright, good to know. I looked at it briefly a while back to see if there was something other than wait_events but didn't immediately find it.

from openrhythm.

Salamandar avatar Salamandar commented on May 27, 2024

Yeah. And my soundio wrapper exposes soundio_flush_events as a direct call to flush_events(&soundio)

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

Something i was thinking about, with the new rendering architecture the main game thread can probably be ran on a totally separate thread from the rendering thread.

from openrhythm.

mdsitton avatar mdsitton commented on May 27, 2024

My current short term plan for this is to just haphazardly add extra threads where they make sense. Longer term i'd like to have some sort of task system where tasks can be launched as a thread.

from openrhythm.

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.