#IJobEntity only using a single worker thread?

1 messages · Page 1 of 1 (latest)

brazen steeple
#

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?

wicked mulch
#

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).

drowsy moat
#

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 ^^"

brazen steeple
wicked mulch
brazen steeple
#

ok cool
thank you :)

ashen aurora
wicked mulch
#

Oh

#

Also there's a missing equal sign here:

this.Dependency rotationsSpeedJob.Schedule(chunks.Length,32, this.Dependency);
ashen aurora
#

IJobParallelFor only has Schedule which confusingly, schedules as parallel compared to every other job

#

while IJobFor has Schedule and ScheduleParallel

#

to provide standardized naming across all jobs as well as the option of not using parallel