numa.h 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <c10/macros/Export.h>
  4. #include <c10/util/Flags.h>
  5. #include <cstddef>
  6. C10_DECLARE_bool(caffe2_cpu_numa_enabled);
  7. namespace c10 {
  8. /**
  9. * Check whether NUMA is enabled
  10. */
  11. C10_API bool IsNUMAEnabled();
  12. /**
  13. * Bind to a given NUMA node
  14. */
  15. C10_API void NUMABind(int numa_node_id);
  16. /**
  17. * Get the NUMA id for a given pointer `ptr`
  18. */
  19. C10_API int GetNUMANode(const void* ptr);
  20. /**
  21. * Get number of NUMA nodes
  22. */
  23. C10_API int GetNumNUMANodes();
  24. /**
  25. * Move the memory pointed to by `ptr` of a given size to another NUMA node
  26. */
  27. C10_API void NUMAMove(void* ptr, size_t size, int numa_node_id);
  28. /**
  29. * Get the current NUMA node id
  30. */
  31. C10_API int GetCurrentNUMANode();
  32. } // namespace c10
  33. #else
  34. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  35. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)