Allow getting and setting CUDA kernel attributes#2369
Allow getting and setting CUDA kernel attributes#2369emcastillo merged 16 commits intocupy:masterfrom
Conversation
add a FuncAttributes class to store all kernel attributes add an attributes property to the RawKernel class. This can be used to query the register and memory usage of the kernel.
refactor attributes test as a separate test case memoize the kernel attributes.
build the dictionary within raw.pyx instead
Moved RawKernel kernel generation into a property to facilitate re-use.
Fixed formatting.
Fixed python 2.x compatibility by making descriptors "new style" classes.
Fixed comment.
…dict; added doc test is also updated
|
We are solving some CI related issues so the merge will take a bit. |
|
Thanks for updating & reviving this PR @leofang. |
|
Jenkins, test this please |
|
Jenkins CI test (for commit 38a3096, target branch master) failed with status FAILURE. |
|
CI has a related failure https://jenkins.preferred.jp/job/chainer/job/cupy_pr/252/TEST=cupy-example,label=mn1-p100/console This is happening only with python2 |
|
@emcastillo what's the version of Cython used in that build? I can't reproduce this error locally in a py27 env. |
|
I guess it's caused by Cython, not by Python version. It also failed on py35: |
|
Let me confirm it tomorrow! Sorry and thanks! |
|
Sure, no worries! |
|
should be 0.28.3 |
|
Tried 0.28.3, worked fine. I am now guessing earlier CUDA versions do not provide |
|
It seems |
|
Please rerun Jenkins for me. Thanks. |
I forgot that I can check it myself! Yeah I think this is the reason. From cupy-py2: 22:11:46 Modules:
22:11:46 cuda : Yes (version 8000)
22:11:46 cudnn : Yes (version 5110)From cupy-doc: 22:11:29 Modules:
22:11:29 cuda : Yes (version 8000)
22:11:29 cudnn : Yes (version 6021)Commit 38fcde8 should fix the problem. |
|
Jenkins, test this please |
|
Jenkins CI test (for commit 38fcde8, target branch master) failed with status FAILURE. |
|
cupy-py3 errors seem irrelevant. cupy-doc should be fixed in 419711a by skipping doctests. The result varies system by system. |
|
Jenkins, test this please |
|
Jenkins CI test (for commit 419711a, target branch master) failed with status FAILURE. |
|
Failures are unrelated |
|
Thank you, @emcastillo, @andravin, and @grlee77 ! |
Takeover of #2120 (which in turn was based on #1874) as @andravin lost interest 😢
Resolves #2118.
Most of the credit goes to @grlee77 and @andravin. I took over as we really need the ability of setting shared memory size for CUDA kernels. I'd like to see this capability merged asap if possible.
Changes compared to #2120:
FunctionAttributesclass is removed. Instead, all function attributes are alsoRawKernel's attributes now. First, I don't like the idea of having a Python object living in acdef'd class just for accessing attributes. As suggested in Setting CUDA function attributes #2118 (comment):Second, I don't want to retrieve attributes through a non-standard object. Finally, the current implementation (using
@propertyand@attribute.setter) is more pythonic, even if it's written in Cython.RawKernel.attributesnow returns a dict of attributes, as suggested by CuPy core dev earlier. This behavior not only avoids the second concern above, but is also in line withcupy.cuda.device.Device().attributes. (However, this is read-only, and to set the attributes one needs to access the target attribute ofRawKerneldirectly.)RawKernelis updated