From dc5a04202db0feb34e7949642d90e1219b2d6e10 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 14 Jul 2022 08:01:02 -0500 Subject: [PATCH] refine allocation cmake (#44241) * build into one static library * move memory/detail to memory/allocation * fix bug * fix profiler * fix framework_proto * fix deps * fix inference compilation * fix rocm compile * follow comments * fix buddy_allocator_test --- cmake/inference_lib.cmake | 6 +- paddle/fluid/memory/CMakeLists.txt | 3 +- paddle/fluid/memory/allocation/CMakeLists.txt | 319 +++++++----------- .../{detail => allocation}/buddy_allocator.cc | 2 +- .../{detail => allocation}/buddy_allocator.h | 4 +- .../buddy_allocator_test.cc | 4 +- .../{detail => allocation}/memory_block.cc | 2 +- .../{detail => allocation}/memory_block.h | 0 .../memory_block_desc.cc | 2 +- .../{detail => allocation}/meta_cache.cc | 2 +- .../allocation/naive_best_fit_allocator.cc | 4 +- .../system_allocator.cc | 2 +- .../{detail => allocation}/system_allocator.h | 0 .../system_allocator_test.cc | 2 +- .../allocation/thread_local_allocator.h | 4 +- paddle/fluid/memory/detail/CMakeLists.txt | 79 ----- paddle/fluid/memory/pinned_memory_test.cu | 2 +- paddle/fluid/platform/CMakeLists.txt | 4 +- .../platform/device/gpu/cuda/CMakeLists.txt | 2 +- paddle/fluid/platform/profiler.cc | 2 + paddle/fluid/platform/profiler.h | 5 +- paddle/fluid/pybind/CMakeLists.txt | 4 - 22 files changed, 144 insertions(+), 310 deletions(-) rename paddle/fluid/memory/{detail => allocation}/buddy_allocator.cc (99%) rename paddle/fluid/memory/{detail => allocation}/buddy_allocator.h (97%) rename paddle/fluid/memory/{detail => allocation}/buddy_allocator_test.cc (99%) rename paddle/fluid/memory/{detail => allocation}/memory_block.cc (98%) rename paddle/fluid/memory/{detail => allocation}/memory_block.h (100%) rename paddle/fluid/memory/{detail => allocation}/memory_block_desc.cc (97%) rename paddle/fluid/memory/{detail => allocation}/meta_cache.cc (97%) rename paddle/fluid/memory/{detail => allocation}/system_allocator.cc (99%) rename paddle/fluid/memory/{detail => allocation}/system_allocator.h (100%) rename paddle/fluid/memory/{detail => allocation}/system_allocator_test.cc (97%) delete mode 100644 paddle/fluid/memory/detail/CMakeLists.txt diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 56345373dbe..865dd8643d8 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -427,10 +427,8 @@ copy( set(module "memory") copy( fluid_lib_dist - SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/detail/*.h - ${src_dir}/${module}/allocation/*.h - DSTS ${dst_dir}/${module} ${dst_dir}/${module}/detail - ${dst_dir}/${module}/allocation) + SRCS ${src_dir}/${module}/allocation/*.h + DSTS ${dst_dir}/${module}/allocation) set(module "platform") set(platform_lib_deps profiler_proto errors) diff --git a/paddle/fluid/memory/CMakeLists.txt b/paddle/fluid/memory/CMakeLists.txt index 5d1f97c096b..eccba465051 100644 --- a/paddle/fluid/memory/CMakeLists.txt +++ b/paddle/fluid/memory/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(detail) add_subdirectory(allocation) if(WITH_MKLDNN) @@ -10,7 +9,7 @@ endif() cc_library( malloc SRCS malloc.cc - DEPS place enforce allocator_facade profiler ${MKLDNN_CTX_DEPS}) + DEPS place enforce allocator profiler ${MKLDNN_CTX_DEPS}) cc_library( memcpy SRCS memcpy.cc diff --git a/paddle/fluid/memory/allocation/CMakeLists.txt b/paddle/fluid/memory/allocation/CMakeLists.txt index 46a46b04b3e..ec8391469f9 100644 --- a/paddle/fluid/memory/allocation/CMakeLists.txt +++ b/paddle/fluid/memory/allocation/CMakeLists.txt @@ -1,264 +1,179 @@ -cc_library( - allocator - SRCS allocator.cc - DEPS place stats profiler) -cc_library( - cpu_allocator - SRCS cpu_allocator.cc - DEPS allocator) -cc_library( - locked_allocator - SRCS locked_allocator.cc - DEPS allocator) -cc_library( - buffered_allocator - SRCS buffered_allocator.cc - DEPS allocator) -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) -cc_test( - naive_best_fit_allocator_test - SRCS naive_best_fit_allocator_test.cc - DEPS naive_best_fit_allocator) -cc_test( - buffered_allocator_test - SRCS buffered_allocator_test.cc - DEPS locked_allocator buffered_allocator cpu_allocator best_fit_allocator) +include(ExternalProject) + +set(ALLOCATOR_DEPS place stats profiler) +set(ALLOCATOR_SRCS + allocator.cc + cpu_allocator.cc + locked_allocator.cc + aligned_allocator.cc + buffered_allocator.cc + best_fit_allocator.cc + naive_best_fit_allocator.cc + allocator_strategy.cc + allocator_facade.cc + auto_growth_best_fit_allocator.cc + virtual_memory_auto_growth_best_fit_allocator.cc + retry_allocator.cc + memory_block.cc + memory_block_desc.cc + meta_cache.cc + buddy_allocator.cc + system_allocator.cc) -if(WITH_MKLDNN) - set(MKLDNN_CTX_DEPS mkldnn) -else() - set(MKLDNN_CTX_DEPS) +if(WITH_GPU OR WITH_ROCM) + list( + APPEND + ALLOCATOR_SRCS + cuda_allocator.cc + cuda_managed_allocator.cc + pinned_allocator.cc + stream_safe_cuda_allocator.cc + thread_local_allocator.cc) + list(APPEND ALLOCATOR_DEPS cuda_device_guard gpu_info dynload_cuda) endif() if(WITH_GPU) - nv_library( - cuda_allocator - SRCS cuda_allocator.cc - DEPS allocator cuda_device_guard stats) - nv_library( - cuda_managed_allocator - SRCS cuda_managed_allocator.cc - DEPS allocator cuda_device_guard gpu_info) - nv_library( - pinned_allocator - SRCS pinned_allocator.cc - DEPS allocator) - nv_library( - stream_safe_cuda_allocator - SRCS stream_safe_cuda_allocator.cc - DEPS allocator cuda_graph) - nv_library( - thread_local_allocator - SRCS thread_local_allocator.cc - DEPS allocator) + list(APPEND ALLOCATOR_DEPS cuda_graph) +endif() - cc_test( - thread_local_allocator_test - SRCS thread_local_allocator_test.cc - DEPS thread_local_allocator) - if(CUDA_VERSION GREATER_EQUAL 10.2) - nv_library( - cuda_virtual_mem_allocator - SRCS cuda_virtual_mem_allocator.cc - DEPS dynload_cuda) +if(CUDA_VERSION VERSION_GREATER_EQUAL 10.2) + list(APPEND ALLOCATOR_SRCS cuda_virtual_mem_allocator.cc) +endif() + +if(NOT WIN32) + list(APPEND ALLOCATOR_SRCS mmap_allocator.cc) + if(WITH_GPU) + list(APPEND ALLOCATOR_SRCS cuda_ipc_allocator.cc) endif() endif() -if(WITH_ROCM) - hip_library( - cuda_allocator - SRCS cuda_allocator.cc - DEPS allocator cuda_device_guard stats) - hip_library( - cuda_managed_allocator - SRCS cuda_managed_allocator.cc - DEPS allocator cuda_device_guard gpu_info) - hip_library( - pinned_allocator - SRCS pinned_allocator.cc - DEPS allocator) - 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) +if(WITH_ASCEND_CL) + list(APPEND ALLOCATOR_SRCS npu_allocator.cc npu_pinned_allocator.cc) + list(APPEND ALLOCATOR_DEPS npu_info) +endif() - cc_test( - thread_local_allocator_test - SRCS thread_local_allocator_test.cc - DEPS thread_local_allocator) +if(WITH_CUSTOM_DEVICE) + list(APPEND ALLOCATOR_SRCS custom_allocator.cc) + list(APPEND ALLOCATOR_DEPS device_manager) endif() -if(WITH_ASCEND_CL) - cc_library( - npu_allocator - SRCS npu_allocator.cc - DEPS allocator npu_info) - cc_library( - npu_pinned_allocator - SRCS npu_pinned_allocator.cc - DEPS allocator npu_info) +if(WITH_XPU) + list(APPEND ALLOCATOR_DEPS xpu_info) endif() -cc_library( - retry_allocator - SRCS retry_allocator.cc +if(WITH_IPU) + list(APPEND ALLOCATOR_DEPS ipu_info) +endif() + +add_library(allocator "${ALLOCATOR_SRCS}") +target_link_libraries(allocator ${ALLOCATOR_DEPS}) +# note: why only add dependency for framework_proto. +# Because it is needed to generate framework.pb.h used in some header files. +add_dependencies(allocator framework_proto) +set_property(GLOBAL PROPERTY FLUID_MODULES allocator) + +cc_test( + naive_best_fit_allocator_test + SRCS naive_best_fit_allocator_test.cc + DEPS allocator) +cc_test( + buffered_allocator_test + SRCS buffered_allocator_test.cc DEPS allocator) -if(WITH_GPU OR WITH_ROCM) - set(AllocatorFacadeDeps - gpu_info - cuda_allocator - cuda_managed_allocator - pinned_allocator - cuda_device_guard - thread_local_allocator - stream_safe_cuda_allocator - device_context) - if(CUDA_VERSION GREATER_EQUAL 10.2) - list(APPEND AllocatorFacadeDeps cuda_virtual_mem_allocator) - endif() -elseif(WITH_XPU) - set(AllocatorFacadeDeps xpu_info) -elseif(WITH_IPU) - set(AllocatorFacadeDeps ipu_info) -elseif(WITH_ASCEND) - set(AllocatorFacadeDeps ascend_npu_info) -else() - set(AllocatorFacadeDeps) +if(WITH_GPU) + nv_test( + thread_local_allocator_test + SRCS thread_local_allocator_test.cc + DEPS allocator) endif() - -if(WITH_CUSTOM_DEVICE) - cc_library( - custom_allocator - SRCS custom_allocator.cc - DEPS allocator device_manager) - set(AllocatorFacadeDeps ${AllocatorFacadeDeps} custom_allocator) +if(WITH_ROCM) + hip_test( + thread_local_allocator_test + SRCS thread_local_allocator_test.cc + DEPS allocator) endif() 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) + DEPS allocator memcpy) 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) + DEPS allocator memcpy) else() cc_test( best_fit_allocator_test SRCS best_fit_allocator_test.cc - DEPS best_fit_allocator locked_allocator cpu_allocator) -endif() - -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) - -if(WITH_ASCEND_CL) - list(APPEND AllocatorFacadeDeps npu_pinned_allocator) + DEPS allocator) endif() -cc_library( - aligned_allocator - SRCS aligned_allocator.cc - DEPS allocator) cc_test( test_aligned_allocator SRCS test_aligned_allocator.cc - DEPS aligned_allocator) -cc_library( - allocator_strategy - SRCS allocator_strategy.cc - DEPS gflags ${AllocatorFacadeDeps}) -cc_library( - allocator_facade - SRCS allocator_facade.cc - DEPS allocator_strategy stats) - -if(WITH_GPU) - target_link_libraries(allocator_facade cuda_graph) -endif() + DEPS allocator) cc_test( retry_allocator_test SRCS retry_allocator_test.cc - DEPS retry_allocator locked_allocator cpu_allocator) -if(WITH_TESTING) - if((WITH_GPU OR WITH_ROCM) AND TARGET retry_allocator_test) - target_link_libraries(retry_allocator_test cuda_allocator) - endif() - - if(TEST retry_allocator_test) - set_tests_properties(retry_allocator_test PROPERTIES LABELS - "RUN_TYPE=EXCLUSIVE") - endif() + DEPS allocator) +if(TEST retry_allocator_test) + set_tests_properties(retry_allocator_test PROPERTIES LABELS + "RUN_TYPE=EXCLUSIVE") endif() cc_test( allocator_facade_abs_flags_test SRCS allocator_facade_abs_flags_test.cc - DEPS allocator_facade) + DEPS allocator) cc_test( allocator_facade_frac_flags_test SRCS allocator_facade_frac_flags_test.cc - DEPS allocator_facade) + DEPS allocator) -cc_library( - auto_growth_best_fit_allocator - SRCS auto_growth_best_fit_allocator.cc - DEPS allocator aligned_allocator flags) 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) + DEPS allocator) cc_test( auto_growth_best_fit_allocator_test SRCS auto_growth_best_fit_allocator_test.cc - DEPS auto_growth_best_fit_allocator) - -cc_library( - virtual_memory_auto_growth_best_fit_allocator - SRCS virtual_memory_auto_growth_best_fit_allocator.cc - DEPS allocator aligned_allocator) + DEPS allocator) 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) - if(WITH_GPU) - cc_library( - cuda_ipc_allocator - SRCS cuda_ipc_allocator.cc - DEPS allocator) + DEPS allocator) +endif() + +cc_test( + system_allocator_test + SRCS system_allocator_test.cc + DEPS allocator) + +cc_test( + buddy_allocator_test + SRCS buddy_allocator_test.cc + DEPS allocator) + +if(WITH_TESTING) + if(TEST buddy_allocator_test) + set_tests_properties(buddy_allocator_test PROPERTIES LABELS + "RUN_TYPE=EXCLUSIVE") + endif() + + # TODO(zhiqiu): why not win32? because wget is not found on windows + if(NOT WIN32) + add_custom_target( + download_data + COMMAND wget -nc + https://paddle-ci.cdn.bcebos.com/buddy_allocator_test_data.tar + COMMAND tar -xf buddy_allocator_test_data.tar) + add_dependencies(buddy_allocator_test download_data) endif() endif() diff --git a/paddle/fluid/memory/detail/buddy_allocator.cc b/paddle/fluid/memory/allocation/buddy_allocator.cc similarity index 99% rename from paddle/fluid/memory/detail/buddy_allocator.cc rename to paddle/fluid/memory/allocation/buddy_allocator.cc index 90cce14c567..907fd37e442 100644 --- a/paddle/fluid/memory/detail/buddy_allocator.cc +++ b/paddle/fluid/memory/allocation/buddy_allocator.cc @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/memory/detail/buddy_allocator.h" +#include "paddle/fluid/memory/allocation/buddy_allocator.h" #include diff --git a/paddle/fluid/memory/detail/buddy_allocator.h b/paddle/fluid/memory/allocation/buddy_allocator.h similarity index 97% rename from paddle/fluid/memory/detail/buddy_allocator.h rename to paddle/fluid/memory/allocation/buddy_allocator.h index 463e3cfcf6d..5e39e21c966 100644 --- a/paddle/fluid/memory/detail/buddy_allocator.h +++ b/paddle/fluid/memory/allocation/buddy_allocator.h @@ -25,8 +25,8 @@ limitations under the License. */ #include #include -#include "paddle/fluid/memory/detail/memory_block.h" -#include "paddle/fluid/memory/detail/system_allocator.h" +#include "paddle/fluid/memory/allocation/memory_block.h" +#include "paddle/fluid/memory/allocation/system_allocator.h" #include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/device/npu/npu_info.h" diff --git a/paddle/fluid/memory/detail/buddy_allocator_test.cc b/paddle/fluid/memory/allocation/buddy_allocator_test.cc similarity index 99% rename from paddle/fluid/memory/detail/buddy_allocator_test.cc rename to paddle/fluid/memory/allocation/buddy_allocator_test.cc index ab558e8bfce..ad53a784502 100644 --- a/paddle/fluid/memory/detail/buddy_allocator_test.cc +++ b/paddle/fluid/memory/allocation/buddy_allocator_test.cc @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/memory/detail/buddy_allocator.h" +#include "paddle/fluid/memory/allocation/buddy_allocator.h" #include @@ -330,7 +330,7 @@ TEST(BuddyAllocator, SpeedAna) { std::vector vec_free_flag; std::string line; - int size, id; + int size = 0, id = 0; while (in_file >> size >> id) { vec_size.push_back(size); vec_pos.push_back(id); diff --git a/paddle/fluid/memory/detail/memory_block.cc b/paddle/fluid/memory/allocation/memory_block.cc similarity index 98% rename from paddle/fluid/memory/detail/memory_block.cc rename to paddle/fluid/memory/allocation/memory_block.cc index 52f7d33aae1..0f0a81cf9d1 100644 --- a/paddle/fluid/memory/detail/memory_block.cc +++ b/paddle/fluid/memory/allocation/memory_block.cc @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/memory/detail/memory_block.h" +#include "paddle/fluid/memory/allocation/memory_block.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/detail/memory_block.h b/paddle/fluid/memory/allocation/memory_block.h similarity index 100% rename from paddle/fluid/memory/detail/memory_block.h rename to paddle/fluid/memory/allocation/memory_block.h diff --git a/paddle/fluid/memory/detail/memory_block_desc.cc b/paddle/fluid/memory/allocation/memory_block_desc.cc similarity index 97% rename from paddle/fluid/memory/detail/memory_block_desc.cc rename to paddle/fluid/memory/allocation/memory_block_desc.cc index 93d2559c37f..d20d56a6d05 100644 --- a/paddle/fluid/memory/detail/memory_block_desc.cc +++ b/paddle/fluid/memory/allocation/memory_block_desc.cc @@ -15,7 +15,7 @@ limitations under the License. */ #include #include -#include "paddle/fluid/memory/detail/memory_block.h" +#include "paddle/fluid/memory/allocation/memory_block.h" namespace paddle { namespace memory { diff --git a/paddle/fluid/memory/detail/meta_cache.cc b/paddle/fluid/memory/allocation/meta_cache.cc similarity index 97% rename from paddle/fluid/memory/detail/meta_cache.cc rename to paddle/fluid/memory/allocation/meta_cache.cc index 4831e005c84..945b0f7b892 100644 --- a/paddle/fluid/memory/detail/meta_cache.cc +++ b/paddle/fluid/memory/allocation/meta_cache.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "glog/logging.h" -#include "paddle/fluid/memory/detail/memory_block.h" +#include "paddle/fluid/memory/allocation/memory_block.h" #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc index d696b8bffda..d1a3b77e772 100644 --- a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc @@ -18,8 +18,8 @@ #include "gflags/gflags.h" #include "glog/logging.h" -#include "paddle/fluid/memory/detail/buddy_allocator.h" -#include "paddle/fluid/memory/detail/system_allocator.h" +#include "paddle/fluid/memory/allocation/buddy_allocator.h" +#include "paddle/fluid/memory/allocation/system_allocator.h" #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/detail/system_allocator.cc b/paddle/fluid/memory/allocation/system_allocator.cc similarity index 99% rename from paddle/fluid/memory/detail/system_allocator.cc rename to paddle/fluid/memory/allocation/system_allocator.cc index eb5c74e56d6..fcfece978cb 100644 --- a/paddle/fluid/memory/detail/system_allocator.cc +++ b/paddle/fluid/memory/allocation/system_allocator.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES -#include "paddle/fluid/memory/detail/system_allocator.h" +#include "paddle/fluid/memory/allocation/system_allocator.h" #include "paddle/fluid/memory/stats.h" diff --git a/paddle/fluid/memory/detail/system_allocator.h b/paddle/fluid/memory/allocation/system_allocator.h similarity index 100% rename from paddle/fluid/memory/detail/system_allocator.h rename to paddle/fluid/memory/allocation/system_allocator.h diff --git a/paddle/fluid/memory/detail/system_allocator_test.cc b/paddle/fluid/memory/allocation/system_allocator_test.cc similarity index 97% rename from paddle/fluid/memory/detail/system_allocator_test.cc rename to paddle/fluid/memory/allocation/system_allocator_test.cc index dbf3fad6c33..4749ff3f8ad 100644 --- a/paddle/fluid/memory/detail/system_allocator_test.cc +++ b/paddle/fluid/memory/allocation/system_allocator_test.cc @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/memory/detail/system_allocator.h" +#include "paddle/fluid/memory/allocation/system_allocator.h" #include diff --git a/paddle/fluid/memory/allocation/thread_local_allocator.h b/paddle/fluid/memory/allocation/thread_local_allocator.h index 3b71ec866b6..a2c9e813f7a 100644 --- a/paddle/fluid/memory/allocation/thread_local_allocator.h +++ b/paddle/fluid/memory/allocation/thread_local_allocator.h @@ -18,8 +18,8 @@ #include #include "paddle/fluid/memory/allocation/allocator.h" -#include "paddle/fluid/memory/detail/buddy_allocator.h" -#include "paddle/fluid/memory/detail/system_allocator.h" +#include "paddle/fluid/memory/allocation/buddy_allocator.h" +#include "paddle/fluid/memory/allocation/system_allocator.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" namespace paddle { diff --git a/paddle/fluid/memory/detail/CMakeLists.txt b/paddle/fluid/memory/detail/CMakeLists.txt deleted file mode 100644 index afe5c0dba0f..00000000000 --- a/paddle/fluid/memory/detail/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -include(ExternalProject) - -cc_library( - memory_block - SRCS memory_block.cc memory_block_desc.cc meta_cache.cc - DEPS place) - -if(WITH_GPU) - nv_library( - system_allocator - SRCS system_allocator.cc - DEPS gflags cpu_info gpu_info place) -elseif(WITH_ROCM) - hip_library( - system_allocator - SRCS system_allocator.cc - DEPS gflags cpu_info gpu_info place) -elseif(${WITH_ASCEND_CL}) - cc_library( - system_allocator - SRCS system_allocator.cc - DEPS gflags cpu_info npu_info place) -elseif(WITH_MLU) - cc_library( - system_allocator - SRCS system_allocator.cc - DEPS gflags cpu_info mlu_info place) -else() - cc_library( - system_allocator - SRCS system_allocator.cc - DEPS gflags cpu_info place) -endif() - -cc_test( - system_allocator_test - SRCS system_allocator_test.cc - DEPS system_allocator) - -cc_library( - buddy_allocator - SRCS buddy_allocator.cc - DEPS memory_block system_allocator glog) - -cc_test( - buddy_allocator_test - SRCS buddy_allocator_test.cc - DEPS buddy_allocator) - -function(file_download_and_uncompress URL NAME) - message(STATUS "Download dependence[${NAME}] from ${URL}") - set(${NAME}_INCLUDE_DIR - ${THIRD_PARTY_PATH}/${NAME} - PARENT_SCOPE) - ExternalProject_Add( - 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() - -if(WITH_TESTING) - if(TEST buddy_allocator_test) - set_tests_properties(buddy_allocator_test PROPERTIES LABELS - "RUN_TYPE=EXCLUSIVE") - endif() - set(URL "https://paddle-ci.cdn.bcebos.com/buddy_allocator_test_data.tar") - file_download_and_uncompress(URL "buddy_allocator") -endif() diff --git a/paddle/fluid/memory/pinned_memory_test.cu b/paddle/fluid/memory/pinned_memory_test.cu index 5b982f62c86..259222754e8 100644 --- a/paddle/fluid/memory/pinned_memory_test.cu +++ b/paddle/fluid/memory/pinned_memory_test.cu @@ -15,7 +15,7 @@ limitations under the License. */ #include -#include "paddle/fluid/memory/detail/memory_block.h" +#include "paddle/fluid/memory/allocation/memory_block.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/platform/cpu_info.h" diff --git a/paddle/fluid/platform/CMakeLists.txt b/paddle/fluid/platform/CMakeLists.txt index 2ff31aa5b54..2374cfdfd34 100644 --- a/paddle/fluid/platform/CMakeLists.txt +++ b/paddle/fluid/platform/CMakeLists.txt @@ -88,12 +88,12 @@ if(WITH_GPU) nv_library( cuda_graph_with_memory_pool SRCS cuda_graph_with_memory_pool.cc - DEPS device_context allocator_facade cuda_graph) + DEPS device_context allocator cuda_graph) else() cc_library( cuda_graph_with_memory_pool SRCS cuda_graph_with_memory_pool.cc - DEPS device_context allocator_facade) + DEPS device_context allocator) endif() cc_library( diff --git a/paddle/fluid/platform/device/gpu/cuda/CMakeLists.txt b/paddle/fluid/platform/device/gpu/cuda/CMakeLists.txt index 15c7a6c4624..64a2f891c21 100644 --- a/paddle/fluid/platform/device/gpu/cuda/CMakeLists.txt +++ b/paddle/fluid/platform/device/gpu/cuda/CMakeLists.txt @@ -1,7 +1,7 @@ nv_library( cuda_graph SRCS cuda_graph.cc - DEPS enforce allocator_facade) + DEPS enforce) nv_library( cuda_profiler SRCS cuda_profiler.cc diff --git a/paddle/fluid/platform/profiler.cc b/paddle/fluid/platform/profiler.cc index 38471251ff4..d02fd545788 100644 --- a/paddle/fluid/platform/profiler.cc +++ b/paddle/fluid/platform/profiler.cc @@ -310,8 +310,10 @@ RecordOpInfoSupplement::RecordOpInfoSupplement( std::map>> RecordMemEvent::size_cache; + std::map> RecordMemEvent::has_initialized; + RecordMemEvent::RecordMemEvent(const void *ptr, const phi::Place &place, size_t size, diff --git a/paddle/fluid/platform/profiler.h b/paddle/fluid/platform/profiler.h index 4773b1a177b..6046e54b6c8 100644 --- a/paddle/fluid/platform/profiler.h +++ b/paddle/fluid/platform/profiler.h @@ -28,7 +28,6 @@ limitations under the License. */ #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/event.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/profiler.pb.h" #include "paddle/fluid/platform/profiler/event_tracing.h" #include "paddle/fluid/platform/profiler/mem_tracing.h" #include "paddle/fluid/platform/profiler/supplement_tracing.h" @@ -39,6 +38,10 @@ limitations under the License. */ namespace paddle { namespace platform { +namespace proto { +class Profile; +} + const int kEnableProfiler = 1; const int kDisableProfiler = 2; diff --git a/paddle/fluid/pybind/CMakeLists.txt b/paddle/fluid/pybind/CMakeLists.txt index f301189d778..63ebffe9f25 100755 --- a/paddle/fluid/pybind/CMakeLists.txt +++ b/paddle/fluid/pybind/CMakeLists.txt @@ -84,10 +84,6 @@ endif() if(NOT WIN32) set(PYBIND_DEPS ${PYBIND_DEPS} data_loader) - set(PYBIND_DEPS ${PYBIND_DEPS} mmap_allocator) - if(WITH_GPU) - set(PYBIND_DEPS ${PYBIND_DEPS} cuda_ipc_allocator) - endif() if(WITH_NCCL OR WITH_RCCL) set(PYBIND_DEPS ${PYBIND_DEPS} nccl_context) set(PYBIND_DEPS ${PYBIND_DEPS} heter_ccl_context) -- GitLab