CUDAMacros.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #ifndef C10_USING_CUSTOM_GENERATED_MACROS
  4. // We have not yet modified the AMD HIP build to generate this file so
  5. // we add an extra option to specifically ignore it.
  6. #ifndef C10_CUDA_NO_CMAKE_CONFIGURE_FILE
  7. #include <c10/cuda/impl/cuda_cmake_macros.h>
  8. #endif // C10_CUDA_NO_CMAKE_CONFIGURE_FILE
  9. #endif
  10. // See c10/macros/Export.h for a detailed explanation of what the function
  11. // of these macros are. We need one set of macros for every separate library
  12. // we build.
  13. #ifdef _WIN32
  14. #if defined(C10_CUDA_BUILD_SHARED_LIBS)
  15. #define C10_CUDA_EXPORT __declspec(dllexport)
  16. #define C10_CUDA_IMPORT __declspec(dllimport)
  17. #else
  18. #define C10_CUDA_EXPORT
  19. #define C10_CUDA_IMPORT
  20. #endif
  21. #else // _WIN32
  22. #if defined(__GNUC__)
  23. #define C10_CUDA_EXPORT __attribute__((__visibility__("default")))
  24. #else // defined(__GNUC__)
  25. #define C10_CUDA_EXPORT
  26. #endif // defined(__GNUC__)
  27. #define C10_CUDA_IMPORT C10_CUDA_EXPORT
  28. #endif // _WIN32
  29. // This one is being used by libc10_cuda.so
  30. #ifdef C10_CUDA_BUILD_MAIN_LIB
  31. #define C10_CUDA_API C10_CUDA_EXPORT
  32. #else
  33. #define C10_CUDA_API C10_CUDA_IMPORT
  34. #endif
  35. /**
  36. * The maximum number of GPUs that we recognizes. Increasing this beyond the
  37. * initial limit of 16 broke Caffe2 testing, hence the ifdef guards.
  38. * This value cannot be more than 128 because our DeviceIndex is a uint8_t.
  39. o */
  40. #ifdef FBCODE_CAFFE2
  41. // fbcode depends on this value being 16
  42. #define C10_COMPILE_TIME_MAX_GPUS 16
  43. #else
  44. #define C10_COMPILE_TIME_MAX_GPUS 120
  45. #endif
  46. #else
  47. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  48. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)