ecst
ecst copied to clipboard
Help with my configuration
Hey,
I for some reason can't seem to get one of my systems to run in parallel. Could you take a look at my configuration? Basically one of my systems has all my opengl code in it, that system crashes if multiple threads try and run it.
I configured my system to run singlethreaded, or atleast I thought I did, but the evidence shows my "rendering system" is being executed by multiple threads. Any ideas?
proof (using gdb, system initially runs on thread #1, later segfaults on thread #4):

configuration: https://github.com/bjadamson/BoomHS/blob/ecst/include/game/boomhs/boomhs.hpp#L198-L206
example I copied: https://github.com/SuperV1234/ecst/blob/948491e47e11327cff8f62a04fe02fda3c08bd6d/example/pres_code.cpp#L766
The actual system code is here, and maybe important. I only expect the whole "system" to be executed serially, because I disabled inner parallelism. Is that expectation correct? https://github.com/bjadamson/BoomHS/blob/ecst/include/game/boomhs/boomhs.hpp#L43-L55 https://github.com/bjadamson/BoomHS/blob/ecst/include/game/boomhs/boomhs.hpp#L236
Thx !!
Your current configurations says:
s::render_triangleands::io_systemcan run in parallel.- All entities subscribed to
s::render_trianglewill be processed in a single subtask (single-threaded). - All entities subscribed to
s::io_systemwill be processed in a single subtask (single-threaded).
There is no guarantee that the single-threaded systems will be executed on the main thread - their single subtask will be sent to the thread pool as any other subtask. The guarantee is that the system won't be split in multiple subtasks. There is no guarantee that a particular system will be executed on the same thread multiple times (i.e. could run on thread 1 on first frame, on thread 4 on second frame).
Is this a possible cause of your issue?
Ok, looks like you had some insight into the problem I didn't have yet. The exact crash is because sdl and opengl have expectations on the thread that created them being the same thread all future draw calls from, kind-of sort-of I mostly understand it, I think.
So, it seems like the obvious solution is to just not put this code into a system, and write it directly into the main loop around the call to step(...). Does this seem reasonable?
If so, follow up question. I'd like to iterate over the entities using the same syntax outside of a "system" (because of the reasoning right above) to iterate over my "red_triangle" components (be kind, I'm still just trying to integrate the library with opengl/sdl). Is this possible? So far the only API's I can find for iterating over the entities looks like this: https://github.com/SuperV1234/ecst/blob/master/example/particles.cpp#L444-L451
Is there an API for iterating over components/entities outside of the context of one of these proxy.execute_systems() ... functions?
Either that, or do you think it would be more straight forward to "pin" the task somehow to a thread? I guess I could look into implementing this if you think that's smart. It does feel like it goes against the spirit of the library (parallel everything), but I'm unsure how to use opengl/sdl with the library without further inquiry.