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

Speed up ElementwiseKernel launch #1318

Merged
merged 12 commits into from
Jul 26, 2018
Merged

Conversation

okuta
Copy link
Member

@okuta okuta commented Jun 3, 2018

test code

before
python adam.py 7.55s user 0.68s system 99% cpu 8.234 total
python adam.py 7.57s user 0.71s system 99% cpu 8.291 total
python adam.py 7.74s user 0.70s system 99% cpu 8.456 total
python adam.py 7.82s user 0.66s system 99% cpu 8.482 total

after
python adam.py 5.04s user 0.67s system 99% cpu 5.711 total
python adam.py 4.76s user 0.68s system 99% cpu 5.454 total
python adam.py 4.82s user 0.66s system 99% cpu 5.492 total
python adam.py 4.92s user 0.70s system 99% cpu 5.637 total

@okuta okuta added the cat:enhancement Improvements to existing features label Jun 3, 2018
@okuta okuta added this to the v5.0.0b2 milestone Jun 3, 2018
@okuta okuta changed the title Introduce _CScalar type to up speed of ElementwiseKernel launching Speed ​​up ElementwiseKernel startup Jun 3, 2018
@okuta okuta changed the title Speed ​​up ElementwiseKernel startup Speed ​​up ElementwiseKernel launch Jun 3, 2018
@kmaehashi
Copy link
Member

@@ -106,9 +111,14 @@ cdef _int_type = _int_iinfo.dtype.type

cpdef _python_scalar_to_numpy_scalar(x):
# Note that isinstance(x, six_integer_types) matches with bool.
if isinstance(x, bool):
typ = type(x)
Copy link
Member

Choose a reason for hiding this comment

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

Is it safe? x could be of some type derived from Python built-in scalars.

Copy link
Member Author

Choose a reason for hiding this comment

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

Previous code uses _python_type_to_numpy_type.

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean we are not going to support such types?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I will add fallback code.

Copy link
Member

Choose a reason for hiding this comment

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

(By the way, I'm not insisting we should support them. But if we are not going to support them, it's better to make consensus and write in the documentation.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I found this condition.
Already, the input data is filtered by it.

Copy link
Member

Choose a reason for hiding this comment

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

I can't follow the link you pasted, but if there's assumption on this function, it's better to write in a comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

@okuta okuta force-pushed the introduce-cscalar branch 3 times, most recently from 336b0e7 to e912c6e Compare June 13, 2018 10:52
@okuta
Copy link
Member Author

okuta commented Jun 13, 2018

I rebased.

@chainer-ci
Copy link
Member

Jenkins CI test failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@kmaehashi
Copy link
Member

Jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@chainer-ci
Copy link
Member

Jenkins CI test (for commit
56cf755) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 56cf755) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@okuta okuta added cat:performance Performance in terms of speed or memory consumption to-be-backported Pull-requests to be backported to stable branch labels Jun 17, 2018
@okuta okuta force-pushed the introduce-cscalar branch 2 times, most recently from 39f0dd4 to 8367883 Compare June 17, 2018 05:55
@okuta
Copy link
Member Author

okuta commented Jun 17, 2018

Note that use of C++11 may break build on CentOS 6. Actually we once reverted to avoid this (#732). It may be accepted as we now have wheels, though.

@kmaehashi I change to use c++0x instead of c++11.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 8367883) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

from cupy.core cimport internal


cdef dict _typenames_base = {
Copy link
Member

Choose a reason for hiding this comment

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

Are these mapping safe?
e.g. can we assume long long == int64?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I do not change this code.

cpdef CScalar _python_scalar_to_c_scalar(x):
cdef CScalar ret = CScalar()
typ = type(x)
if x is bool:
Copy link
Member

Choose a reason for hiding this comment

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

x -> typ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks

@okuta
Copy link
Member Author

okuta commented Jun 19, 2018

I fixed.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit d4e0210) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 661cdfb) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@beam2d beam2d modified the milestones: v5.0.0b2, v5.0.0b3 Jun 21, 2018
@okuta
Copy link
Member Author

okuta commented Jul 17, 2018

jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 6920986) succeeded without errors!

@kmaehashi kmaehashi modified the milestones: v5.0.0b3, v5.0.0b4 Jul 18, 2018
Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

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

LGTM except for the line I commented.

@@ -206,8 +208,30 @@ def test_invalid_stop_type(self):
{'x': 2 ** 40, 'expect': 2 ** 40},
{'x': 2 ** 40 - 1, 'expect': 2 ** 40},
{'x': 2 ** 40 + 1, 'expect': 2 ** 41},
{'x': 2 ** 40 + 1, 'expect': 2 ** 41},
Copy link
Member

Choose a reason for hiding this comment

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

This set of parameters is already in the test.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed.

@toslunar
Copy link
Member

Jenkins, test this please.

@chainer-ci
Copy link
Member

Jenkins CI test (for commit f51d899, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@toslunar
Copy link
Member

The Jenkins failure ( tests.chainer_tests.functions_tests.normalization_tests.test_l2_normalization.TestL2Normalization_param_38.test_backward_cpu) is irrelevant to the PR.

@toslunar toslunar self-assigned this Jul 26, 2018
@toslunar toslunar merged commit 2b809fa into cupy:master Jul 26, 2018
@toslunar toslunar changed the title Speed ​​up ElementwiseKernel launch Speed up ElementwiseKernel launch Jul 26, 2018
toslunar added a commit that referenced this pull request Jul 26, 2018
Speed up ElementwiseKernel launch
toslunar added a commit to toslunar/cupy that referenced this pull request Jul 26, 2018
Speed ​​up ElementwiseKernel launch
@chainer-ci
Copy link
Member

Jenkins CI test (for commit f51d899, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@okuta
Copy link
Member Author

okuta commented Jul 27, 2018

Thanks!

@okuta okuta deleted the introduce-cscalar branch July 27, 2018 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:enhancement Improvements to existing features cat:performance Performance in terms of speed or memory consumption to-be-backported Pull-requests to be backported to stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants