|
|
|
@ -16,6 +16,7 @@
|
|
|
|
|
#include <random>
|
|
|
|
|
#include <thread> // NOLINT
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include "paddle/fluid/memory/allocation/best_fit_allocator.h"
|
|
|
|
|
#include "paddle/fluid/memory/allocation/cuda_allocator.h"
|
|
|
|
@ -41,12 +42,14 @@ TEST(BestFitAllocator, concurrent_cuda) {
|
|
|
|
|
LockedAllocator concurrent_allocator(
|
|
|
|
|
std::unique_ptr<Allocator>(new BestFitAllocator(cuda_allocation.get())));
|
|
|
|
|
|
|
|
|
|
platform::CUDAPlace gpu(0);
|
|
|
|
|
platform::CUDADeviceContext dev_ctx(gpu);
|
|
|
|
|
|
|
|
|
|
auto th_main = [&](std::random_device::result_type seed) {
|
|
|
|
|
std::default_random_engine engine(seed);
|
|
|
|
|
std::uniform_int_distribution<size_t> dist(1U, 1024U);
|
|
|
|
|
platform::CUDAPlace gpu(0);
|
|
|
|
|
platform::CUDADeviceContext dev_ctx(gpu);
|
|
|
|
|
std::array<size_t, 1024> buf;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 128; ++i) {
|
|
|
|
|
size_t allocate_size = dist(engine);
|
|
|
|
|
|
|
|
|
|