So, I'm very new to using the ECS and I'm currently using it for a neural network project. The general idea is that I have a number of "brains," which are entities with DynamicBuffers attached that hold the neuron activations and layer characteristics. I've created an IJobEntity to fire the neural networks, and my expectation was that it would try to take advantage of all the worker threads. I've created a test IJob that performs exactly the same functions except it doesn't pull data from the entities, and it performs exactly as I expect -- all 22 of my worker threads fill with the jobs and they all execute in parallel. In contrast, my IJobEntity is instead running on a single worker thread. I would have expected that each entity would get its own worker thread until they were all full, and then repeat from worker thread 0. But it seems like what actually happens is it's treated as one long, sequential operation and shoved onto a single thread. I've tried using Schedule() and ScheduleParallel() and it doesn't seem to make a difference. What's going on under the hood here?
#IJobEntity only using a single worker thread?
1 messages · Page 1 of 1 (latest)
When you write an IJobEntity, Unity creates an IJobChunk from it and that's the real job that will run, IJobEntity just allows you to avoid writing more boilerplate code. So if there is only 1 chunk with these brain entities then there will only be 1 instance of the job using a single worker thread. You can check how many chunks there are for each archetype in the Archetypes window (Window -> Entities).
IJobEntity executes its work per chunk behind the scenes (you can inspect the codegen, i dont remember where it is though), so if your data fits within a single chunk, it may end up using just one thread As OverMighty said, i didnt see his reply ^^"
So if I wanted to have it dedicate a thread per entity instead of per chunk is IJob the best way of going about that?
I think you mean IJobParallelFor as IJob runs on a single worker thread afaik, but yes I think so.
ok cool
thank you :)
I think you mean IJobFor 😄, shouldn't really use IJobParallelFor anymore as it's just the legacy version
Oh
Might want to change the Entities manual then: https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/iterating-manually.html
Also there's a missing equal sign here:
this.Dependency rotationsSpeedJob.Schedule(chunks.Length,32, this.Dependency);