CMakeLists.txt 2.0 KB
Newer Older
1
add_subdirectory(detail)
2
add_subdirectory(allocation)
3

4 5 6 7
if(WITH_MKLDNN)
  set(MKLDNN_CTX_DEPS mkldnn)
else()
  set(MKLDNN_CTX_DEPS)
8 9
endif()

10 11 12 13 14 15 16 17 18 19 20 21
cc_library(
  malloc
  SRCS malloc.cc
  DEPS place enforce allocator_facade profiler ${MKLDNN_CTX_DEPS})
cc_library(
  memcpy
  SRCS memcpy.cc
  DEPS place device_context)
cc_library(
  stats
  SRCS stats.cc
  DEPS enforce)
22
cc_library(memory DEPS malloc memcpy stats)
23

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
cc_test(
  memory_stats_test
  SRCS memory_stats_test.cc
  DEPS memory)
cc_test(
  stats_test
  SRCS stats_test.cc
  DEPS stats)

if(WITH_GPU)
  nv_test(
    malloc_test
    SRCS malloc_test.cu
    DEPS device_context malloc)
  nv_test(
    stream_safe_cuda_alloc_test
    SRCS stream_safe_cuda_alloc_test.cu
    DEPS malloc cuda_graph_with_memory_pool)
  nv_test(
    cuda_managed_memory_test
    SRCS cuda_managed_memory_test.cu
    DEPS malloc gpu_info place)

  if(WITH_TESTING AND TEST stream_safe_cuda_alloc_test)
    set_tests_properties(
      stream_safe_cuda_alloc_test
      PROPERTIES
        ENVIRONMENT
        "FLAGS_use_stream_safe_cuda_allocator=true;FLAGS_allocator_strategy=auto_growth"
    )
  endif()
55 56
endif()

57 58 59 60 61 62 63 64 65
if(WITH_ROCM)
  hip_test(
    malloc_test
    SRCS malloc_test.cu
    DEPS device_context malloc)
  hip_test(
    cuda_managed_memory_test
    SRCS cuda_managed_memory_test.cu
    DEPS malloc gpu_info place)
66 67 68
endif()

if(WITH_TESTING AND TEST cuda_managed_memory_test)
69 70 71 72 73 74
  set_tests_properties(
    cuda_managed_memory_test
    PROPERTIES
      ENVIRONMENT
      "FLAGS_use_cuda_managed_memory=true;FLAGS_allocator_strategy=auto_growth"
      TIMEOUT 50)
75 76
endif()

77 78 79 80 81 82 83 84 85 86
if(WITH_GPU
   AND WITH_TESTING
   AND NOT "$ENV{CI_SKIP_CPP_TEST}" STREQUAL "ON")
  nv_test(
    get_base_ptr_test
    SRCS get_base_ptr_test.cu
    DEPS malloc gpu_info)
  set_tests_properties(
    get_base_ptr_test
    PROPERTIES ENVIRONMENT "FLAGS_allocator_strategy=auto_growth;
87 88 89
                                    FLAGS_use_stream_safe_cuda_allocator=true;")
endif()

C
chengduoZH 已提交
90
#if (WITH_GPU)
91
#   nv_test(pinned_memory_test SRCS pinned_memory_test.cu  DEPS place memory)
C
chengduoZH 已提交
92
#endif()