From 2bf51afaa128c39d1e98e90433dc33d1f7f78aaa Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 4 Nov 2016 16:13:32 -0500 Subject: [PATCH] Expand hipP2PSimple testing. Cover cases where P2P is used for H2D copies, where host is pinned but not accessible to the copy agent. Change-Id: I9464b787228b40f93473708c3fde9726e1986365 [ROCm/clr commit: 60a8a5405d124dc13331b7777b161d6a33b3c92e] --- .../hipamd/tests/src/hipPeerToPeer_simple.cpp | 123 ++++++++++++++++-- 1 file changed, 111 insertions(+), 12 deletions(-) diff --git a/projects/clr/hipamd/tests/src/hipPeerToPeer_simple.cpp b/projects/clr/hipamd/tests/src/hipPeerToPeer_simple.cpp index 2c1a3cc339..c2fc2e065c 100644 --- a/projects/clr/hipamd/tests/src/hipPeerToPeer_simple.cpp +++ b/projects/clr/hipamd/tests/src/hipPeerToPeer_simple.cpp @@ -50,6 +50,16 @@ void help(char *argv[]) }; +static hipError_t myHipMemcpy(void *dest, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream, bool async) +{ + if (async) { + return hipMemcpyAsync(dest, src, sizeBytes, kind, stream); + } else { + return hipMemcpy(dest, src, sizeBytes, kind); + }; +} + + void parseMyArguments(int argc, char *argv[]) { int more_argc = HipTest::parseStandardArguments(argc, argv, false); @@ -104,9 +114,9 @@ void setupPeerTests() //--- // Test which enables peer2peer first, then allocates the memory. -void enablePeerFirst() +void enablePeerFirst(bool useAsyncCopy) { - printf ("\n==testing: %s\n", __func__); + printf ("\n==testing: %s useAsyncCopy=%d\n", __func__, useAsyncCopy); setupPeerTests(); @@ -147,11 +157,11 @@ void enablePeerFirst() // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a // a host staging copy for the P2P access. HIPCHECK (hipSetDevice(p_memcpyWithPeer ? g_peerDevice : g_currentDevice)); - HIPCHECK (hipMemcpy(A_d1, A_d0, Nbytes, hipMemcpyDefault)); // This is P2P copy. + HIPCHECK (myHipMemcpy(A_d1, A_d0, Nbytes, hipMemcpyDefault, 0/*stream*/, useAsyncCopy)); // This is P2P copy. // Copy data back to host: HIPCHECK (hipSetDevice(g_peerDevice)); - HIPCHECK (hipMemcpy(A_h, A_d1, Nbytes, hipMemcpyDeviceToHost)); + HIPCHECK (myHipMemcpy(A_h, A_d1, Nbytes, hipMemcpyDeviceToHost, 0/*stream*/, useAsyncCopy)); // Check host data: for (int i=0; i