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

Don't set affinity if didn't specify -ss #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lijing0010
Copy link
Contributor

User can still use taskset to specify the cores, this works for non-numa
CPU cases

Signed-off-by: Jing Li [email protected]

User can still use taskset to specify the cores, this works for non-numa
CPU cases

Signed-off-by: Jing Li <[email protected]>
@@ -642,8 +642,10 @@ void eb_set_thread_management_parameters( EbSvtVp9EncConfiguration *config_ptr){
if (num_groups == 1) {
uint32_t lps = config_ptr->logical_processors == 0 ? num_logical_processors :
config_ptr->logical_processors < num_logical_processors ? config_ptr->logical_processors : num_logical_processors;
for (uint32_t i = 0; i < lps; i++)
CPU_SET(lp_group[0].group[i], &group_affinity);
if (config_ptr->target_socket != -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as for HEVC. The change is not needed.

@Austin-Hu
Copy link
Contributor

Austin-Hu commented Sep 12, 2019

Hi @lijing0010 & @tianjunwork ,

Let's talk about the topic with SVT-HEVC PR #353 together, although the latter one has been merged.

At first, in my opinion, the CPU affinity setting isn't related to the CPU socket or the number of CPU (logic) cores of an SMP system. The "-ss" and "-lp" options wouldn't impact the affinity function (except that some processor bit masks for the "-c" option of taskset will be ommitted, with some "-ss" and "-lp" combination).

As for @lijing0010 's request to use taskset to set affinity for single socket CPU, we can use taskset before launching the encoding process or after encoding is launched. But we should notice that taskset itself calls sched_setaffinity() and then execve to run the specified process, which may also invoke pthread_setaffinity_np() (implemented on top of sched_setaffinity()). In the 2 cases either taskset is before or after encoding process launched, the second call of sched_setaffinity() overrides the first one.

But each encoding kernel thread will be bound to unforseen active logic cores via pthread_setaffinity_np() scheduled by Linux kernel scheduler, taskset couldn't have the affinity result which the user targets for, like what @lijing0010 concerned. So the only way is to launch the encoding process at first, get its PID and then run taskset with "-p" option to override previous affinity setting.

I think both of the 2 PRs should be reverted, otherwise we couldn't get benefit from CPU affinity in case that the user doesn't add the "-ss" option (for single socket CPU). Or both of them should be reworked, by setting CPU affinitiy for all logic cores, only if the returned CPU affinity mask of pthread_getaffinity_np() is all 0 with one bit position excluded.

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants