Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Thread Backend]Fix CPU Thread Binding for Multiple Sockets #5918

Merged
merged 2 commits into from
Jun 25, 2020

Conversation

kevinthesun
Copy link
Contributor

@kevinthesun kevinthesun commented Jun 24, 2020

TVM randomly binds master thread onto available cores. If there are multiple CPU sockets, it is possible that thread binds can cross sockets which causes NUMA. This PR limits the ranged of cores in TVM_NUM_THREADS so that on multi-socket machines we can limit thread binding within single socket.

@yidawang @FrozenGene

Copy link
Contributor

@yidawang yidawang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me to fix the NUMA issue. Conceptually, this is a better setting as you don't want the master thread to freely jump to the cores that you are not required. However, generally speaking, I think the current setting (beyond the scope of this PR) doesn't consider the case of multiple instances running simultaneously, which could be a potential issue.

int big_count = big_count_;
// Imagine our x86 has cores 0 - 7
// physical cores are 0 - 3, logical cores are 4 - 7, big_count_ is 8
// we wish we run on physical cores, not logical cores to avoid contention issue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The big count might be necessary for the big.little ARM targets

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible to detect big.LITTLE somewhere?

Copy link
Member

@tqchen tqchen Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to look into the code. Perhaps do num_binds = std::min(MaxConcurrency(), big_count_); to keep backward compact for BIG.LITTLE

@tqchen
Copy link
Member

tqchen commented Jun 24, 2020

cc @FrozenGene @junrushao1994

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Learned something from the PR and the comments. Thanks!

@tqchen tqchen merged commit 524552a into apache:master Jun 25, 2020
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 30, 2020
)

* Fix CPU Thread Binding for Multiple Sockets

* Backward compatibility
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Jul 2, 2020
)

* Fix CPU Thread Binding for Multiple Sockets

* Backward compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants