| 92 | |
| 93 | template<typename T> |
| 94 | void 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 | |
| 123 | template<typename T> |
| 124 | void memAllocPtrScopeTest(int elements) { |
nothing calls this directly
no test coverage detected