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

Function TYPED_TEST

test/sparse.cpp:227–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225TYPED_TEST_SUITE(Sparse, SparseTypes);
226
227TYPED_TEST(Sparse, DeepCopy) {
228 SUPPORTED_TYPE_CHECK(TypeParam);
229
230 cleanSlate();
231
232 array s;
233 {
234 // Create a sparse array from a dense array. Make sure that the dense
235 // arrays are removed
236 array dense = randu(10, 10);
237 array d = makeSparse<TypeParam>(dense, 5);
238 s = sparse(d);
239 }
240
241 // At this point only the sparse array will be allocated in memory.
242 // Determine how much memory is allocated by one sparse array
243 size_t alloc_bytes, alloc_buffers;
244 size_t lock_bytes, lock_buffers;
245
246 deviceMemInfo(&alloc_bytes, &alloc_buffers, &lock_bytes, &lock_buffers);
247 size_t size_of_alloc = lock_bytes;
248 size_t buffers_per_sparse = lock_buffers;
249
250 {
251 array s2 = s.copy();
252 s2.eval();
253
254 // Make sure that the deep copy allocated additional memory
255 deviceMemInfo(&alloc_bytes, &alloc_buffers, &lock_bytes, &lock_buffers);
256
257 EXPECT_NE(s.get(), s2.get()) << "The sparse arrays point to the same "
258 "af_array object.";
259 EXPECT_EQ(size_of_alloc * 2, lock_bytes)
260 << "The number of bytes allocated by the deep copy do "
261 "not match the original array";
262
263 EXPECT_EQ(buffers_per_sparse * 2, lock_buffers)
264 << "The number of buffers allocated by the deep "
265 "copy do not match the original array";
266 array d = dense(s);
267 array d2 = dense(s2);
268 ASSERT_ARRAYS_EQ(d, d2);
269 }
270}
271
272TYPED_TEST(Sparse, Empty) {
273 SUPPORTED_TYPE_CHECK(TypeParam);

Callers

nothing calls this directly

Calls 12

cleanSlateFunction · 0.85
randuFunction · 0.85
sparseFunction · 0.85
deviceMemInfoFunction · 0.85
denseFunction · 0.85
sparseGetNNZFunction · 0.85
af_release_arrayFunction · 0.50
arrayClass · 0.50
copyMethod · 0.45
evalMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected