Skip to content

Add attributes property to RawKernel#1874

Closed
grlee77 wants to merge 7 commits intocupy:masterfrom
grlee77:func_attributes_v2
Closed

Add attributes property to RawKernel#1874
grlee77 wants to merge 7 commits intocupy:masterfrom
grlee77:func_attributes_v2

Conversation

@grlee77
Copy link
Copy Markdown
Member

@grlee77 grlee77 commented Dec 9, 2018

It is helpful to be able to query kernel attributes such as the number of registers that a RawKernel is using. The implementation in this PR is based on wrapping cuFuncGetAttributes from the Driver API.

I think a couple of these attiributes (maxDynamicSharedSizeBytes and preferredShmemCarveout) did not exist in CUDA 8.0. To deal with this, any attributes that return status CUDA_ERROR_INVALID_VALUE get set to -1 to indicate they are unavailable.

Note:
I initially tried using cudaFuncGetAttributes from the Runtime API (which reads all of the attributes into a structure in one call). However, when I tried passing in the kernel function I always got:

CUDARuntimeError: cudaErrorInvalidDeviceFunction: invalid device function

Perhaps this is because extern "C" is used for the RawKernel source, but I am not sure.

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.
@okuta okuta added the cat:feature New features/APIs label Dec 9, 2018
@kmaehashi kmaehashi self-assigned this Dec 9, 2018
@grlee77 grlee77 force-pushed the func_attributes_v2 branch from 460f503 to 79b9f95 Compare December 9, 2018 15:02
@grlee77
Copy link
Copy Markdown
Member Author

grlee77 commented Feb 19, 2019

Any feedback regarding this feature? I find it useful to be able to query the number of registers a RawKernel uses, for example.

Copy link
Copy Markdown
Member

@kmaehashi kmaehashi left a comment

Choose a reason for hiding this comment

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

Thanks, I added some comments.

refactor attributes test as a separate test case

memoize the kernel attributes.
@grlee77
Copy link
Copy Markdown
Member Author

grlee77 commented Feb 26, 2019

Thanks @kmaehashi.
I have followed your suggestion and removed the FuncAttributes class, replacing it with a dict instead. The dict is memoized now as well (in raw.pyx)

I still need to remove funcGetAttributes from driver.pyx if I understand your request correctly, though. I will do that in a separate commit soon.

build the dictionary within raw.pyx instead
@grlee77
Copy link
Copy Markdown
Member Author

grlee77 commented Feb 26, 2019

Okay, this should now be ready for a new review.

@grlee77
Copy link
Copy Markdown
Member Author

grlee77 commented Mar 31, 2019

Please review #2120 prior to reviewing this PR again. That PR is an expansion of this one and adds support for setting attributes as well. I think most likely this PR can be closed in favor of that one.

@grlee77
Copy link
Copy Markdown
Member Author

grlee77 commented Aug 8, 2019

closed in favor of updated version in #2369

@grlee77 grlee77 closed this Aug 8, 2019
@kmaehashi kmaehashi added this to the Closed issues and PRs milestone Aug 22, 2019
@grlee77 grlee77 deleted the func_attributes_v2 branch November 26, 2019 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:feature New features/APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants