From 417b243968bb73308bdc9eaa34bc4081c07a0e52 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Wed, 22 Jul 2020 17:44:49 +0800 Subject: [PATCH] fix best_fit_allocator_test on windows, test=develop (#25650) * fix best_fit_allocator_test on windows, test=develop * enable best_fit_allocator_test and test_math_op_patch_var_base, test=develop --- paddle/fluid/memory/allocation/CMakeLists.txt | 37 +++++++++---------- .../allocation/best_fit_allocator_test.cc | 7 +++- .../fluid/tests/unittests/CMakeLists.txt | 1 - 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/paddle/fluid/memory/allocation/CMakeLists.txt b/paddle/fluid/memory/allocation/CMakeLists.txt index 0816218a0d..bd1908ac65 100644 --- a/paddle/fluid/memory/allocation/CMakeLists.txt +++ b/paddle/fluid/memory/allocation/CMakeLists.txt @@ -27,26 +27,23 @@ else () set(AllocatorFacadeDeps) endif() -# TODO: Fix this unittest failed on Windows -if(NOT WIN32) - 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) - else() - cc_test(best_fit_allocator_test - SRCS best_fit_allocator_test.cc - DEPS best_fit_allocator - locked_allocator - cpu_allocator) - endif() -endif(NOT WIN32) +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) +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 best_fit_allocator) diff --git a/paddle/fluid/memory/allocation/best_fit_allocator_test.cc b/paddle/fluid/memory/allocation/best_fit_allocator_test.cc index fa7662d2f8..d20a6fc0e0 100644 --- a/paddle/fluid/memory/allocation/best_fit_allocator_test.cc +++ b/paddle/fluid/memory/allocation/best_fit_allocator_test.cc @@ -13,11 +13,13 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/best_fit_allocator.h" + #include #include #include // NOLINT #include #include + #include "gtest/gtest.h" #include "paddle/fluid/memory/allocation/cpu_allocator.h" #include "paddle/fluid/memory/allocation/locked_allocator.h" @@ -33,7 +35,10 @@ class StubAllocation : public Allocation { }; TEST(BestFitAllocator, test_allocation) { - StubAllocation stub(4UL * 1024 * 1024 * 1024); + // NOTE(zhiqiu): On windows with msvc compiler, unsigned long (UL) is 32bits, + // so 4UL * 1024 * 1024 * 1024 becomes 0. + // We need to use 4ULL (unsigned long long) here. + StubAllocation stub(4ULL * 1024 * 1024 * 1024); BestFitAllocator allocator(&stub); { auto allocation = allocator.Allocate(64); } diff --git a/python/paddle/fluid/tests/unittests/CMakeLists.txt b/python/paddle/fluid/tests/unittests/CMakeLists.txt index e4a11e5b7a..17893a1218 100644 --- a/python/paddle/fluid/tests/unittests/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/CMakeLists.txt @@ -63,7 +63,6 @@ if(WIN32) list(REMOVE_ITEM TEST_OPS test_merge_ids_op) list(REMOVE_ITEM TEST_OPS test_split_ids_op) LIST(REMOVE_ITEM TEST_OPS test_ref_by_trainer_id_op) - LIST(REMOVE_ITEM TEST_OPS test_math_op_patch_var_base) endif() if(APPLE OR WIN32) -- GitLab