MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/common_runtime/gpu/gpu_bfc_allocator_test.cc:54–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54TEST(GPUBFCAllocatorTest, NoDups) {
55 PlatformGpuId platform_gpu_id(0);
56 GPUMemAllocator* sub_allocator = new GPUMemAllocator(
57 GpuIdUtil::ExecutorForPlatformGpuId(platform_gpu_id).ValueOrDie(),
58 platform_gpu_id, false /*use_unified_memory*/, {}, {});
59 GPUBFCAllocator a(sub_allocator, 1 << 30, "GPU_0_bfc");
60 CheckStats(&a, 0, 0, 0, 0);
61
62 // Allocate a lot of raw pointers
63 std::vector<void*> ptrs;
64 for (int s = 1; s < 1024; s++) {
65 void* raw = a.AllocateRaw(1, s);
66 ptrs.push_back(raw);
67 }
68 CheckStats(&a, 1023, 654336, 654336, 1024);
69
70 std::sort(ptrs.begin(), ptrs.end());
71
72 // Make sure none of them are equal, and that none of them overlap.
73 for (size_t i = 1; i < ptrs.size(); i++) {
74 ASSERT_NE(ptrs[i], ptrs[i - 1]); // No dups
75 size_t req_size = a.RequestedSize(ptrs[i - 1]);
76 ASSERT_GT(req_size, 0);
77 ASSERT_GE(static_cast<char*>(ptrs[i]) - static_cast<char*>(ptrs[i - 1]),
78 req_size);
79 }
80
81 for (size_t i = 0; i < ptrs.size(); i++) {
82 a.DeallocateRaw(ptrs[i]);
83 }
84 CheckStats(&a, 1023, 0, 654336, 1024);
85}
86
87TEST(GPUBFCAllocatorTest, AllocationsAndDeallocations) {
88 PlatformGpuId platform_gpu_id(0);

Callers

nothing calls this directly

Calls 14

sortFunction · 0.85
Rand32Method · 0.80
CheckStatsFunction · 0.70
AllocateRawMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
RequestedSizeMethod · 0.45
DeallocateRawMethod · 0.45
TracksAllocationSizesMethod · 0.45
AllocatedSizeMethod · 0.45

Tested by

no test coverage detected