Skip to content

Commit

Permalink
Add privateuseone flags for c10::EventFlag (#121118)
Browse files Browse the repository at this point in the history
Fixes #117341
Pull Request resolved: #121118
Approved by: https://github.com/albanD
  • Loading branch information
chentianyi16 authored and pytorchmergebot committed Mar 14, 2024
1 parent 9f314d4 commit 0e68eb1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
2 changes: 0 additions & 2 deletions aten/src/ATen/hip/impl/HIPGuardImplMasqueradingAsCUDA.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,9 @@ struct HIPGuardImplMasqueradingAsCUDA final : public c10::impl::DeviceGuardImplI
auto hip_flag = hipEventDefault;
switch (flag) {
case EventFlag::PYTORCH_DEFAULT:
case EventFlag::HIP_EVENT_DISABLE_TIMING:
hip_flag = hipEventDisableTiming;
break;
case EventFlag::BACKEND_DEFAULT:
case EventFlag::HIP_EVENT_DEFAULT:
hip_flag = hipEventDefault;
break;
default:
Expand Down
15 changes: 4 additions & 11 deletions c10/core/impl/DeviceGuardImplInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@ class DataPtr;
* PYTORCH_DEFAULT and BACKEND_DEFAULT are valid for all backends. The
* BACKEND_DEFAULT is what a particular backend would select if no
* flags were given. PYTORCH_DEFAULT is the PyTorch's framework default
* choice for events on that backend, which may not be the same. For example,
* when PyTorch creates a CUDA event it sets the flag
* CUDA_EVENT_DISABLING_TIMING by default to improve performance.
* choice for events on that backend, which may not be the same.
*
* The mapping of PYTORCH_DEFAULT and BACKEND_DEFAULT is done by each
* backend implementation. Backend-specific flags, like CUDA_EVENT_DEFAULT,
* should map one-to-one with actual event flags for those backends.
* backend implementation.
*/
enum class EventFlag {
// Disable timing
PYTORCH_DEFAULT,
// Enable timing
BACKEND_DEFAULT,
// CUDA flags
CUDA_EVENT_DEFAULT,
CUDA_EVENT_DISABLE_TIMING, // PyTorch-default for CUDA
// HIP flags
HIP_EVENT_DEFAULT,
HIP_EVENT_DISABLE_TIMING, // PyTorch-default for HIP
// FOR TESTING ONLY
INVALID
};
Expand Down
2 changes: 0 additions & 2 deletions c10/cuda/impl/CUDAGuardImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ struct CUDAGuardImpl final : public c10::impl::DeviceGuardImplInterface {
auto cuda_flag = cudaEventDefault;
switch (flag) {
case EventFlag::PYTORCH_DEFAULT:
case EventFlag::CUDA_EVENT_DISABLE_TIMING:
cuda_flag = cudaEventDisableTiming;
break;
case EventFlag::BACKEND_DEFAULT:
case EventFlag::CUDA_EVENT_DEFAULT:
cuda_flag = cudaEventDefault;
break;
default:
Expand Down

0 comments on commit 0e68eb1

Please sign in to comment.