Comments (1)
Multiple threads accessing the same cache lines is a recipe for massive performance penalties. It's better for threads to work on independent data whenever possible. A common pattern is to have 'worker caches': memory that is modified by only one worker. A worker index lets you find that worker cache.
While you could do something similar with a job index alone, there are typically more jobs than workers within a single dispatch. Having to maintain a cache for every job just wastes memory and potentially increases the cost of any postprocessing over the set of caches.
The worker index being provided directly avoids the need for things like Thread.ManagedThreadId
. Unlike Thread.ManagedThreadId
, the worker indices cover the range [0, N) for a dispatch of N threads, so you can use them to index into different worker caches easily.
While the ThreadDispatcher
assigns the worker indices at thread creation time, you can dynamically assign them at the start of each dispatch. In other words, you can think of IThreadDispatcher.Dispatch
as a for loop from 0 to workerCount. I'm not familiar with unity's job system, but presumably there's some type of parallel for loop available.
(It's worth noting that the worker index is not required to map perfectly to a specific OS thread. It's nice where possible, since the OS tends to not shuffle threads between cores every half millisecond, and you'll probably get more cache hits compared to a version that has different thread-workerIndex mappings every dispatch, but the library jumps through some hoops to limit the number of dispatches. Much of the solver, for example, is one giant dispatch that manages its own scheduling.)
from bepuphysics2.
Related Issues (20)
- no collision with mesh colliders HOT 7
- Body always sleeping HOT 2
- Does this mean that when end_point0 =new EdgeEndpoints(){A=0,B=3}, end_point1 =new EdgeEndpoints(){A=1,B=2}, their hash values are equal HOT 2
- The change in tree cost is an invalid value, strongly implying the tree bounds have been corrupted by infinites or NaNs. HOT 7
- Cylinder Convex Hull Tester HOT 9
- bug: endless loop when create ConvexHull HOT 3
- support multihread tracing which export chrome tracing format data HOT 2
- Broad and Narrow Phase HOT 1
- `Tree.BinnedBuild` multithreaded determinism options HOT 1
- Debug assert with wrong resolution. HOT 3
- Is there any way to bring the api level down to C#8.0 HOT 1
- How should sensors be implemented? HOT 1
- When will version 2.5 be released? HOT 6
- Cube/Plane not Simulating in ECS-based Physics Setup HOT 7
- Sleeper exhibits performance cliff at >4,000,000 active bodies HOT 1
- Initializing big compound with only 1 member results in some weird internal tree error. HOT 2
- Consider incremental tree refines on insertion HOT 1
- Instability caused by ApplyImpulse HOT 1
- Tree metanodes contain obsolete data
- Regressions on 16-wide vectors HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bepuphysics2.