Skip to content

[Performance fix] Make GetBlob assuming elements are cached #38336

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

Merged
merged 3 commits into from
Dec 23, 2021

Conversation

jczaja
Copy link
Contributor

@jczaja jczaja commented Dec 21, 2021

PR types

Performance optimization

PR changes

Others

Describe

GetBlob is very often used function and majority of it is executed under critical section so it is good to optimize it as much as possible. In this PR we add assumption that objects in cache are there e.g. we instruct compiler to generate code layout in favour of situation that objects are cached. Performance improvement is x < 1% on mobilenetv1_int8 CLX

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@jczaja jczaja added the Intel label Dec 21, 2021
@jczaja jczaja requested a review from jakpiase December 22, 2021 12:02
@jczaja
Copy link
Contributor Author

jczaja commented Dec 22, 2021

@pawelpiotrowicz , @tsocha , @Silv3S, @piotrekobiIntel, @zuzg Please review

Copy link
Contributor

@pawelpiotrowicz pawelpiotrowicz left a comment

Choose a reason for hiding this comment

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

LGTM

#define likely(expr) (expr)
#define unlikely(expr) (expr)
#else
#define likely(expr) (__builtin_expect(!!(expr), 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are using double !! ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

__builtin_expect does accept long integer arguments. Comparison among boolean and int may raise a warning. So it was "double negated" so True is converted to 1, False to 0 and compared with long in of 1 or 0.

Copy link
Member

@Silv3S Silv3S left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jakpiase jakpiase left a comment

Choose a reason for hiding this comment

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

LGTM

@jczaja
Copy link
Contributor Author

jczaja commented Dec 22, 2021

@Aganlengzi Please review and merge if correct

@jczaja jczaja requested a review from Aganlengzi December 22, 2021 15:05
Copy link
Contributor

@arlesniak arlesniak left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@sfraczek sfraczek left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Aganlengzi Aganlengzi left a comment

Choose a reason for hiding this comment

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

LGTM

@Aganlengzi Aganlengzi merged commit 7da5368 into PaddlePaddle:develop Dec 23, 2021
@lidanqing-intel lidanqing-intel changed the title Make GetBlob assuming elements are cached [Performance fix] Make GetBlob assuming elements are cached Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants