Skip to content

Commit

Permalink
Fix ReleaseUnused test.
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
  • Loading branch information
mzient committed Jan 16, 2023
1 parent ce1e43b commit d989761
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dali/core/mm/default_resource_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ TEST(MMDefaultResource, ReleaseUnused) {
auto *dev = mm::GetDefaultDeviceResource(0);
auto *pinned = mm::GetDefaultResource<mm::memory_kind::pinned>();

CUDA_CALL(cudaDeviceSynchronize());
mm::ReleaseUnusedMemory();

size_t free0 = 0; // before allocation
Expand All @@ -308,7 +309,7 @@ TEST(MMDefaultResource, ReleaseUnused) {
size_t free3 = 0; // ReleaseUnused called after deallocation
size_t total = 0;

cudaMemGetInfo(&free0, &total);
CUDA_CALL(cudaMemGetInfo(&free0, &total));
ssize_t min_dev_size = 256;
ssize_t dev_size = free0 - (64_z << 20); // all free memory - 64 MiB
ssize_t pinned_size = 256_z << 20; // 256 MiB
Expand All @@ -332,15 +333,16 @@ TEST(MMDefaultResource, ReleaseUnused) {

mm::ReleaseUnusedMemory();
CUDA_CALL(cudaMemGetInfo(&free2, &total));
EXPECT_EQ(free2, free1);
EXPECT_EQ(free2, free1) << "Nothing should have been released.";

mem_dev.reset();
mem_pinned.reset();

mm::ReleaseUnusedMemory();
CUDA_CALL(cudaMemGetInfo(&free3, &total));
EXPECT_GT(free3, free2);
EXPECT_EQ(free3, free0);
// GE, because we might actually get more memory if some Managed Memory has been reclaimed
EXPECT_GE(free3, free0);
}

TEST(MMDefaultResource, PreallocateDeviceMemory) {
Expand Down

0 comments on commit d989761

Please sign in to comment.