-
Notifications
You must be signed in to change notification settings - Fork 7
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
cp.async access global tensor via pointer #2282
Conversation
tensor_most_positive_index += (tensor_input.size(dim_i) - 1) * | ||
tensor_input.stride(dim_i) * tensor_input.element_size(); | ||
} else { | ||
// Acuumulate negative stride | ||
tensor_most_negative_index += | ||
(tensor_input.size(dim_i) - 1) * tensor_input.stride(dim_i); | ||
tensor_most_negative_index += (tensor_input.size(dim_i) - 1) * | ||
tensor_input.stride(dim_i) * tensor_input.element_size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: index mode change. Some 32-bit indexable kernels now will need 64-bit indexing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worthwhile to do this if it requires switching the indexing for an entire kernel from 32-bit to 64-bit?
@zasdfgbnm What's the status of this PR? |
I haven't get time to work on this yet. Will work on it this week. |
I changed this PR to use |
Does this only affect tensors read with |
Right, should only affect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments for now. Trying to remember what this PR is about.
TORCH_CUDA_CU_API bool isIntegralType(DataType dtype); | ||
// Returns if the datatype is a pointer type | ||
TORCH_CUDA_CU_API bool isPointerType(DataType dtype); | ||
// Returns if the datatype is an boolean type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "a boolean" (thanks for fixing the misplaced comments)
Where is this logic implemented? |
Which tests would show the pointer addressing? |
It is controlled by the |
There is no test for it. But I can change some existing tests to check this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. It would be great to add some check to a test that should use this pointer addressing.
According to #1974, it looks like accessing global memory via
char *
delivers better performance. Plus, the base pointer is just an integral scalar and can be passed through the index hoisting and simplification pipeline just like any other scalar. It does not need to be handled separately.Example kernel from
NVFuserTest.FusionLargeWelfordNormalization_CUDA
:TODO: run benchmark