CMakeLists.txt 1.9 KB
Newer Older
1 2
include(ExternalProject)

3 4 5 6
cc_library(
  memory_block
  SRCS memory_block.cc memory_block_desc.cc meta_cache.cc
  DEPS place)
Y
Yi Wang 已提交
7

8
if(WITH_GPU)
9 10 11 12
  nv_library(
    system_allocator
    SRCS system_allocator.cc
    DEPS gflags cpu_info gpu_info place)
13
elseif(WITH_ROCM)
14 15 16 17
  hip_library(
    system_allocator
    SRCS system_allocator.cc
    DEPS gflags cpu_info gpu_info place)
18
elseif(${WITH_ASCEND_CL})
19 20 21 22
  cc_library(
    system_allocator
    SRCS system_allocator.cc
    DEPS gflags cpu_info npu_info place)
F
fwenguang 已提交
23
elseif(WITH_MLU)
24 25 26 27
  cc_library(
    system_allocator
    SRCS system_allocator.cc
    DEPS gflags cpu_info mlu_info place)
28
else()
29 30 31 32
  cc_library(
    system_allocator
    SRCS system_allocator.cc
    DEPS gflags cpu_info place)
33
endif()
34

35 36 37 38
cc_test(
  system_allocator_test
  SRCS system_allocator_test.cc
  DEPS system_allocator)
L
liaogang 已提交
39

40 41 42 43
cc_library(
  buddy_allocator
  SRCS buddy_allocator.cc
  DEPS memory_block system_allocator glog)
44

45 46 47 48
cc_test(
  buddy_allocator_test
  SRCS buddy_allocator_test.cc
  DEPS buddy_allocator)
49

50 51 52 53 54
function(file_download_and_uncompress URL NAME)
  message(STATUS "Download dependence[${NAME}] from ${URL}")
  set(${NAME}_INCLUDE_DIR
      ${THIRD_PARTY_PATH}/${NAME}
      PARENT_SCOPE)
55
  ExternalProject_Add(
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    extern_download_${NAME}
    ${EXTERNAL_PROJECT_LOG_ARGS}
    PREFIX ${THIRD_PARTY_PATH}/${NAME}
    URL ${URL}
    DOWNLOAD_DIR ${THIRD_PARTY_PATH}/${NAME}
    SOURCE_DIR ${THIRD_PARTY_PATH}/${NAME}
    DOWNLOAD_NO_PROGRESS 1
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    UPDATE_COMMAND ""
    INSTALL_COMMAND "")
  set(third_party_deps
      ${third_party_deps} extern_download_${NAME}
      PARENT_SCOPE)
endfunction()
71

72
if(WITH_TESTING)
73
  if(TEST buddy_allocator_test)
74 75
    set_tests_properties(buddy_allocator_test PROPERTIES LABELS
                                                         "RUN_TYPE=EXCLUSIVE")
76
  endif()
77 78
  set(URL "https://paddle-ci.cdn.bcebos.com/buddy_allocator_test_data.tar")
  file_download_and_uncompress(URL "buddy_allocator")
79
endif()