adstraw commented on code in PR #13381:
URL: https://github.com/apache/tvm/pull/13381#discussion_r1023115540


##########
tests/cpp-runtime/hexagon/hexagon_user_dma_tests.cc:
##########
@@ -224,3 +228,124 @@ TEST_F(HexagonUserDMATest, overflow_ring_buffer) {
     ASSERT_EQ(src_char[i], dst_char[i]);
   }
 }
+
+TEST_F(HexagonUserDMATest, sync_dma_bypass) {
+  HexagonBuffer srchb(length, kHexagonAllocAlignment, global_scope);
+  HexagonBuffer dsthb(length, kHexagonAllocAlignment, global_scope);
+  HexagonBuffer vtcmhb(length, kHexagonAllocAlignment, global_vtcm_scope);
+
+  // init src, dst HexagonBuffers
+  srchb.CopyFrom(src, length);
+  dsthb.CopyFrom(dst, length);
+
+  // DDR src -> VTCM
+  ret = user_dma->Copy(queue_id, vtcmhb.GetPointer(), srchb.GetPointer(), 
length, ENABLE_BYPASS);
+  ASSERT_EQ(ret, DMA_SUCCESS);
+
+  // VTCM -> DDR dst
+  ret = user_dma->Copy(queue_id, dsthb.GetPointer(), vtcmhb.GetPointer(), 
length, ENABLE_BYPASS);
+  ASSERT_EQ(ret, DMA_SUCCESS);
+
+  // wait for DMAs to complete
+  user_dma->Wait(queue_id, 0);
+
+  // copy answer from dst HexagonBuffer
+  dsthb.CopyTo(dst, length);
+
+  // verify
+  for (uint32_t i = 0; i < length; ++i) {
+    ASSERT_EQ(src_char[i], dst_char[i]);
+  }
+}
+
+TEST_F(HexagonUserDMATest, sync_dma_bypass_vtcm_to_vtcm) {
+  HexagonBuffer srchb(length, kHexagonAllocAlignment, global_scope);
+  HexagonBuffer dsthb(length, kHexagonAllocAlignment, global_scope);
+  HexagonBuffer vtcm1hb(length, kHexagonAllocAlignment, global_vtcm_scope);
+  HexagonBuffer vtcm2hb(length, kHexagonAllocAlignment, global_vtcm_scope);
+
+  // init src, dst HexagonBuffers
+  srchb.CopyFrom(src, length);
+  dsthb.CopyFrom(dst, length);
+
+  // DDR src -> VTCM
+  ret = user_dma->Copy(queue_id, vtcm1hb.GetPointer(), srchb.GetPointer(), 
length, ENABLE_BYPASS);
+  ASSERT_EQ(ret, DMA_SUCCESS);
+
+  // VTCM -> VTCM
+  // NOTE: Cache bypass is disabled for VTCM -> VTCM transfers
+  ret =
+      user_dma->Copy(queue_id, vtcm2hb.GetPointer(), vtcm1hb.GetPointer(), 
length, DISABLE_BYPASS);

Review Comment:
   You can say "enabled" or "disabled" and it will still work.  Here is how the 
code operates:
   
   1) Sets bypass ON for VTCM -> DDR or DDR -> VTCM when the user enables bypass
   2) Sets bypass OFF for VTCM -> VTCM or DDR -> DDR regardless of whether the 
user enables bypass
   
   Not sure if we should a) assert in case (2) when the user enables bypass or 
b) just silently turn bypass OFF.  Currently I opt for (b) but I am open to 
feedback.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to