TraceSpan.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. /*
  3. * Copyright (c) Meta Platforms, Inc. and affiliates.
  4. * All rights reserved.
  5. *
  6. * This source code is licensed under the BSD-style license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. #pragma once
  10. #include <atomic>
  11. #include <string>
  12. #include <thread>
  13. namespace libkineto {
  14. struct TraceSpan {
  15. TraceSpan() = delete;
  16. TraceSpan(int64_t startTime, int64_t endTime, std::string name)
  17. : startTime(startTime), endTime(endTime), name(std::move(name)) {}
  18. TraceSpan(int opCount, int it, std::string name, std::string prefix)
  19. : opCount(opCount),
  20. iteration(it),
  21. name(std::move(name)),
  22. prefix(std::move(prefix)) {}
  23. // FIXME: change to duration?
  24. int64_t startTime{0};
  25. int64_t endTime{0};
  26. int opCount{0};
  27. int iteration{-1};
  28. // Name is used to identify timeline
  29. std::string name;
  30. // Prefix used to distinguish trace spans on the same timeline
  31. std::string prefix;
  32. };
  33. } // namespace libkineto
  34. #else
  35. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  36. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)