CMakeLists.txt 5.8 KB
Newer Older
1 2 3
cc_library(allocator SRCS allocator.cc DEPS place)
cc_library(cpu_allocator SRCS cpu_allocator.cc DEPS allocator)
cc_library(locked_allocator SRCS locked_allocator.cc DEPS allocator)
S
sneaxiy 已提交
4
cc_library(buffered_allocator SRCS buffered_allocator.cc DEPS allocator)
5 6
cc_library(best_fit_allocator SRCS best_fit_allocator.cc DEPS allocator)
cc_library(naive_best_fit_allocator SRCS naive_best_fit_allocator.cc DEPS allocator buddy_allocator profiler)
7
cc_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc DEPS naive_best_fit_allocator)
8
cc_test(buffered_allocator_test SRCS buffered_allocator_test.cc DEPS locked_allocator buffered_allocator cpu_allocator best_fit_allocator)
S
sneaxiy 已提交
9

10 11 12 13 14 15
if (WITH_MKLDNN)
  set(MKLDNN_CTX_DEPS mkldnn)
else ()
  set(MKLDNN_CTX_DEPS)
endif()

S
sneaxiy 已提交
16 17
if (WITH_GPU)
  nv_library(cuda_allocator SRCS cuda_allocator.cc DEPS allocator cuda_device_guard)
18
  nv_library(cuda_managed_allocator SRCS cuda_managed_allocator.cc DEPS allocator cuda_device_guard gpu_info)
19
  nv_library(pinned_allocator SRCS pinned_allocator.cc DEPS allocator)
20 21 22
  nv_library(stream_safe_cuda_allocator SRCS stream_safe_cuda_allocator.cc DEPS allocator)
  nv_library(thread_local_allocator SRCS thread_local_allocator.cc DEPS allocator)

23
  cc_test(thread_local_allocator_test SRCS thread_local_allocator_test.cc DEPS thread_local_allocator)
24 25 26
  if(CUDA_VERSION GREATER_EQUAL 10.2)
    nv_library(cuda_virtual_mem_allocator SRCS cuda_virtual_mem_allocator.cc DEPS dynload_cuda)
  endif()
27 28 29 30
endif()

if (WITH_ROCM)
  hip_library(cuda_allocator SRCS cuda_allocator.cc DEPS allocator cuda_device_guard)
31
  hip_library(cuda_managed_allocator SRCS cuda_managed_allocator.cc DEPS allocator cuda_device_guard gpu_info)
32
  hip_library(pinned_allocator SRCS pinned_allocator.cc DEPS allocator)
33 34 35
  hip_library(stream_safe_cuda_allocator SRCS stream_safe_cuda_allocator.cc DEPS allocator)
  hip_library(thread_local_allocator SRCS thread_local_allocator.cc DEPS allocator)
  
36
  cc_test(thread_local_allocator_test SRCS thread_local_allocator_test.cc DEPS thread_local_allocator)
S
sneaxiy 已提交
37
endif()
38

39 40
if (WITH_ASCEND_CL)
  cc_library(npu_allocator SRCS npu_allocator.cc DEPS allocator npu_info)
41
  cc_library(npu_pinned_allocator SRCS npu_pinned_allocator.cc DEPS allocator npu_info)
42 43
endif()

S
sneaxiy 已提交
44 45
cc_library(retry_allocator SRCS retry_allocator.cc DEPS allocator)

46
if (WITH_GPU OR WITH_ROCM)
47
    set(AllocatorFacadeDeps gpu_info cuda_allocator cuda_managed_allocator pinned_allocator cuda_device_guard thread_local_allocator stream_safe_cuda_allocator device_context)
48 49 50
    if(CUDA_VERSION GREATER_EQUAL 10.2)
      list(APPEND AllocatorFacadeDeps cuda_virtual_mem_allocator)
    endif()
51 52
elseif(WITH_XPU)
    set(AllocatorFacadeDeps xpu_info)
J
jianghaicheng 已提交
53 54
elseif(WITH_IPU)
    set(AllocatorFacadeDeps ipu_info)
55 56
elseif(WITH_ASCEND)
    set(AllocatorFacadeDeps ascend_npu_info)
57 58 59 60
else ()
    set(AllocatorFacadeDeps)
endif()

61 62 63 64 65
if (WITH_CUSTOM_DEVICE)
  cc_library(custom_allocator SRCS custom_allocator.cc DEPS allocator device_manager)
  set(AllocatorFacadeDeps ${AllocatorFacadeDeps} custom_allocator)
endif()

66 67 68 69 70 71 72 73 74 75
if (WITH_GPU)
    nv_test(best_fit_allocator_test
            SRCS best_fit_allocator_test.cc
                best_fit_allocator_test.cu
            DEPS best_fit_allocator
                locked_allocator
                cpu_allocator
                cuda_allocator
                device_context
                memcpy)
76 77 78 79 80 81 82 83 84 85
elseif (WITH_ROCM)
    hip_test(best_fit_allocator_test
            SRCS best_fit_allocator_test.cc
                best_fit_allocator_test.cu
            DEPS best_fit_allocator
                locked_allocator
                cpu_allocator
                cuda_allocator
                device_context
                memcpy)
86 87 88 89 90 91 92
else()
    cc_test(best_fit_allocator_test
            SRCS best_fit_allocator_test.cc
            DEPS best_fit_allocator
                locked_allocator
                cpu_allocator)
endif()
93

94
list(APPEND AllocatorFacadeDeps cpu_allocator locked_allocator aligned_allocator retry_allocator buffered_allocator naive_best_fit_allocator auto_growth_best_fit_allocator virtual_memory_auto_growth_best_fit_allocator best_fit_allocator)
Z
Zeng Jinle 已提交
95

96 97 98 99 100
if (WITH_ASCEND_CL)
    list(APPEND AllocatorFacadeDeps npu_pinned_allocator)
endif()


101
cc_library(aligned_allocator SRCS aligned_allocator.cc DEPS allocator)
102
cc_test(test_aligned_allocator SRCS test_aligned_allocator.cc DEPS aligned_allocator)
Z
Zeng Jinle 已提交
103
cc_library(allocator_strategy SRCS allocator_strategy.cc DEPS gflags ${AllocatorFacadeDeps})
104 105 106 107 108
cc_library(allocator_facade SRCS allocator_facade.cc DEPS allocator_strategy)

if (WITH_GPU)
  target_link_libraries(allocator_facade cuda_graph)
endif()
Y
Yu Yang 已提交
109

110
cc_test(retry_allocator_test SRCS retry_allocator_test.cc DEPS retry_allocator locked_allocator cpu_allocator)
Z
Zeng Jinle 已提交
111
if (WITH_TESTING)
112
  if ((WITH_GPU OR WITH_ROCM) AND TARGET retry_allocator_test)
113 114 115
    target_link_libraries(retry_allocator_test cuda_allocator)
  endif()

116 117 118
  if (TEST retry_allocator_test)
    set_tests_properties(retry_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE")
  endif()
Z
Zeng Jinle 已提交
119 120
endif()

S
sneaxiy 已提交
121 122 123
cc_test(allocator_facade_abs_flags_test SRCS allocator_facade_abs_flags_test.cc DEPS allocator_facade)

cc_test(allocator_facade_frac_flags_test SRCS allocator_facade_frac_flags_test.cc DEPS allocator_facade)
124

Z
Zeng Jinle 已提交
125
cc_library(auto_growth_best_fit_allocator SRCS auto_growth_best_fit_allocator.cc DEPS allocator aligned_allocator flags)
126
cc_test(auto_growth_best_fit_allocator_facade_test SRCS auto_growth_best_fit_allocator_facade_test.cc DEPS cpu_allocator auto_growth_best_fit_allocator)
127
cc_test(auto_growth_best_fit_allocator_test SRCS auto_growth_best_fit_allocator_test.cc DEPS auto_growth_best_fit_allocator)
128

129 130
cc_library(virtual_memory_auto_growth_best_fit_allocator SRCS virtual_memory_auto_growth_best_fit_allocator.cc DEPS allocator aligned_allocator)

131 132 133 134
if(NOT WIN32)
  cc_library(mmap_allocator SRCS mmap_allocator.cc DEPS allocator)
  cc_test(mmap_allocator_test SRCS mmap_allocator_test.cc DEPS mmap_allocator allocator)
endif(NOT WIN32)