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

Avoid using util::function for thread function wrappers #3114

Merged
merged 1 commit into from Jan 20, 2018

Conversation

sithhell
Copy link
Member

Currently, the non-plain versions of the register_work/register_thread functions
make use of util::function. This leads due unnecessary dynamic memory allocation
since the potential for util::function using the small object optimization is
limited.

@sithhell sithhell added this to the 1.1.0 milestone Jan 19, 2018
inline threads::thread_result_type operator()(threads::thread_arg_type)
{
// execute the actual thread function
f();
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The forward has no effect here. It should rather be removed on the other spot. Good catch.

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

Very nice, LGTM!

@hkaiser
Copy link
Member

hkaiser commented Jan 19, 2018

@sithhell how much of an improvement do you see from this change?

@sithhell
Copy link
Member Author

@sithhell how much of an improvement do you see from this change?

For a htts like scenario, with a granularity of 10 us, this is the speedup over current master:

cores, speedup over current master
1    , 1.00102564
2    , 1.0060325 
3    , 1.00424445
4    , 1.00872037
5    , 1.00511072
6    , 1.00440103
7    , 1.00665017
8    , 1.00742586
9    , 1.01019793
10   , 1.01536148
11   , 1.00443919
12   , 1.01483466
13   , 1.00874158
14   , 1.02881041
15   , 1.14408835
16   , 1.20076919

For all other tested grain sizes, there is no noticable difference.

Currently, the non-plain versions of the register_work/register_thread functions
make use of util::function. This leads due unnecessary dynamic memory allocation
since the potential for util::function using the small object optimization is
limited.
@hkaiser hkaiser merged commit 205183b into master Jan 20, 2018
@hkaiser hkaiser deleted the thread_function branch January 20, 2018 13:24
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.

None yet

2 participants