未验证 提交 417b2439 编写于 作者: L Leo Chen 提交者: GitHub

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
上级 3448455b
...@@ -27,26 +27,23 @@ else () ...@@ -27,26 +27,23 @@ else ()
set(AllocatorFacadeDeps) set(AllocatorFacadeDeps)
endif() endif()
# TODO: Fix this unittest failed on Windows if (WITH_GPU)
if(NOT WIN32) nv_test(best_fit_allocator_test
if (WITH_GPU) SRCS best_fit_allocator_test.cc
nv_test(best_fit_allocator_test best_fit_allocator_test.cu
SRCS best_fit_allocator_test.cc DEPS best_fit_allocator
best_fit_allocator_test.cu locked_allocator
DEPS best_fit_allocator cpu_allocator
locked_allocator cuda_allocator
cpu_allocator device_context
cuda_allocator memcpy)
device_context else()
memcpy) cc_test(best_fit_allocator_test
else() SRCS best_fit_allocator_test.cc
cc_test(best_fit_allocator_test DEPS best_fit_allocator
SRCS best_fit_allocator_test.cc locked_allocator
DEPS best_fit_allocator cpu_allocator)
locked_allocator endif()
cpu_allocator)
endif()
endif(NOT WIN32)
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) 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)
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
// limitations under the License. // limitations under the License.
#include "paddle/fluid/memory/allocation/best_fit_allocator.h" #include "paddle/fluid/memory/allocation/best_fit_allocator.h"
#include <memory> #include <memory>
#include <random> #include <random>
#include <thread> // NOLINT #include <thread> // NOLINT
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "paddle/fluid/memory/allocation/cpu_allocator.h" #include "paddle/fluid/memory/allocation/cpu_allocator.h"
#include "paddle/fluid/memory/allocation/locked_allocator.h" #include "paddle/fluid/memory/allocation/locked_allocator.h"
...@@ -33,7 +35,10 @@ class StubAllocation : public Allocation { ...@@ -33,7 +35,10 @@ class StubAllocation : public Allocation {
}; };
TEST(BestFitAllocator, test_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); BestFitAllocator allocator(&stub);
{ auto allocation = allocator.Allocate(64); } { auto allocation = allocator.Allocate(64); }
......
...@@ -63,7 +63,6 @@ if(WIN32) ...@@ -63,7 +63,6 @@ if(WIN32)
list(REMOVE_ITEM TEST_OPS test_merge_ids_op) list(REMOVE_ITEM TEST_OPS test_merge_ids_op)
list(REMOVE_ITEM TEST_OPS test_split_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_ref_by_trainer_id_op)
LIST(REMOVE_ITEM TEST_OPS test_math_op_patch_var_base)
endif() endif()
if(APPLE OR WIN32) if(APPLE OR WIN32)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册