| 42 | |
| 43 | template<typename T> |
| 44 | void writeTest(dim4 dims) { |
| 45 | SUPPORTED_TYPE_CHECK(T); |
| 46 | |
| 47 | array A = randu(dims, (af_dtype)dtype_traits<T>::af_type); |
| 48 | array B = randu(dims, (af_dtype)dtype_traits<T>::af_type); |
| 49 | |
| 50 | array A_copy = A.copy(); |
| 51 | array B_copy = B.copy(); |
| 52 | |
| 53 | T *a_host = A.host<T>(); |
| 54 | T *b_dev = B.device<T>(); |
| 55 | |
| 56 | A.write(b_dev, dims.elements() * sizeof(T), afDevice); |
| 57 | B.write(a_host, dims.elements() * sizeof(T), afHost); |
| 58 | |
| 59 | ASSERT_ARRAYS_EQ(B_copy, A); |
| 60 | ASSERT_ARRAYS_EQ(A_copy, B); |
| 61 | |
| 62 | freeHost(a_host); |
| 63 | } |
| 64 | |
| 65 | TYPED_TEST(Write, Vector0) { writeTest<TypeParam>(dim4(10)); } |
| 66 | |