MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / memAllocArrayScopeTest

Function memAllocArrayScopeTest

test/memory.cpp:94–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93template<typename T>
94void memAllocArrayScopeTest(int elements) {
95 SUPPORTED_TYPE_CHECK(T);
96
97 size_t alloc_bytes, alloc_buffers;
98 size_t lock_bytes, lock_buffers;
99
100 cleanSlate(); // Clean up everything done so far
101
102 {
103 array a = randu(elements, (af_dtype)dtype_traits<T>::af_type);
104
105 deviceMemInfo(&alloc_bytes, &alloc_buffers, &lock_bytes, &lock_buffers);
106
107 ASSERT_EQ(alloc_buffers, 1u);
108 ASSERT_EQ(lock_buffers, 1u);
109
110 ASSERT_EQ(alloc_bytes, roundUpToStep(elements * sizeof(T)));
111 ASSERT_EQ(lock_bytes, roundUpToStep(elements * sizeof(T)));
112 }
113
114 deviceMemInfo(&alloc_bytes, &alloc_buffers, &lock_bytes, &lock_buffers);
115
116 ASSERT_EQ(alloc_buffers, 1u);
117 ASSERT_EQ(lock_buffers, 0u); // 0 because a is out of scope
118
119 ASSERT_EQ(alloc_bytes, roundUpToStep(elements * sizeof(T)));
120 ASSERT_EQ(lock_bytes, 0u);
121}
122
123template<typename T>
124void memAllocPtrScopeTest(int elements) {

Callers

nothing calls this directly

Calls 4

cleanSlateFunction · 0.85
randuFunction · 0.85
deviceMemInfoFunction · 0.85
roundUpToStepFunction · 0.85

Tested by

no test coverage detected