未验证 提交 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 ()
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)
......
......@@ -13,11 +13,13 @@
// limitations under the License.
#include "paddle/fluid/memory/allocation/best_fit_allocator.h"
#include <memory>
#include <random>
#include <thread> // NOLINT
#include <utility>
#include <vector>
#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); }
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册