Comments (3)
I added this description here.
from ipc-toolkit.
With multi-threading enabled, it is expected that the results can be non-deterministic because of rounding differences when adding numbers in different orders. We only utilize TBB in the toolkit (excluding experimental CUDA CCD), so to make the results deterministic you can limit TBB's max number of threads to one. The following code shows how to do this:
#include <tbb/global_control.h>
// ...
tbb::global_control thread_limiter(tbb::global_control::max_allowed_parallelism, 1);
As long as this thread_limiter
object stays alive, the number of threads will be limited to 1. This example shows the thread limiter stack allocated, so when the object goes out-of-scope, the limit will be released. If you want this limit for the entire length of your program it is best to define it in main
or you can define it statically using a std::shared_ptr<tbb::global_control>
. For example,
#include <tbb/info.h>
#include <tbb/global_control.h>
static std::shared_ptr<tbb::global_control> thread_limiter;
void set_num_threads(int nthreads)
{
if (nthreads <= 0) {
nthreads = tbb::info::default_concurrency();
} else if (nthreads > tbb::info::default_concurrency()) {
logger().warn(
"Attempting to use more threads than available ({:d} > {:d})!",
nthreads, tbb::info::default_concurrency());
nthreads = tbb::info::default_concurrency();
}
thread_limiter = std::make_shared<tbb::global_control>(
tbb::global_control::max_allowed_parallelism, nthreads);
}
from ipc-toolkit.
@zfergus: thanks, that's very helpful!
from ipc-toolkit.
Related Issues (16)
- issue in distance_type.tpp HOT 3
- std::array issue HOT 2
- Co-dimensional simulations HOT 4
- EdgeEdgeConstraint distance gradient crash HOT 1
- Questions regarding RigidIPC and GPU CCD HOT 1
- Clarify dimensions of matrix inputs HOT 3
- Slightly confusing documentation for CollisionMesh HOT 4
- Shallow checkout with FetchContent may fail if tag is not HEAD HOT 4
- Unexpectedly slow CCD HOT 13
- Consider changing naming convention to indicate squared distances HOT 3
- Possibly inconsistent results for convergent formulation with respect to dhat? HOT 2
- Average body mass in IPC-toolkit vs average lumped nodal mass in IPC HOT 4
- Basic example of initialization and simulation loop HOT 2
- Closed-form expressions for the Distance Gradients / Hessians HOT 1
- Possible Bug in the Definition of the Hash Structure HOT 2
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 ipc-toolkit.