Added async memcpy driver api

Change-Id: I90e8a078d668a408e79f9e1142e7534771467a4f
This commit is contained in:
Aditya Atluri
2016-09-09 10:21:52 -05:00
والد 9145df8b63
کامیت 2d5140cb27
3فایلهای تغییر یافته به همراه107 افزوده شده و 6 حذف شده
+23 -5
مشاهده پرونده
@@ -6,21 +6,39 @@
#define SIZE LEN<<2
int main(){
int *A, *B, *C;
hipDeviceptr Ad, Bd;
int *A, *B;
hipDeviceptr_t Ad, Bd;
A = new int[LEN];
B = new int[LEN];
C = new int[LEN];
for(int i=0;i<LEN;i++){
A[i] = i;
}
hipMalloc((void**)&Ad, SIZE);
hipMalloc((void**)&Bd, SIZE);
hipMemcpyHtoD(Ad, A, SIZE);
hipMemcpyDtoD(Bd, Ad, SIZE);
hipMemcpyDtoH(B, Bd, SIZE);
hipMemcpyHtoH(C, B,SIZE);
for(int i=0;i<16;i++){
std::cout<<A[i]<<" "<<C[i]<<std::endl;
std::cout<<A[i]<<" "<<B[i]<<std::endl;
}
int *Ah, *Bh;
hipHostMalloc(&Ah, SIZE, 0);
hipHostMalloc(&Bh, SIZE, 0);
memcpy(Ah, A, SIZE);
hipStream_t stream;
hipStreamCreate(&stream);
hipMemcpyHtoDAsync(Ad, Ah, SIZE, stream);
hipStreamSynchronize(stream);
hipMemcpyDtoDAsync(Bd, Ad, SIZE, stream);
hipStreamSynchronize(stream);
hipMemcpyDtoHAsync(Bh, Bd, SIZE, stream);
hipStreamSynchronize(stream);
std::cout<<Ah[10]<<" "<<Bh[10]<<std::endl;
}