Files
rocm-systems/projects/hip/tests/src/hipDrvMemcpy.cpp
T
Aditya Atluri 2efa60a37e Added explicit memory copy direction apis
- Fixed stale printf in context api
- Added 4 sync memcpy apis
  1. hipMemcpyHtoD
  2. hipMemcpyDtoH
  3. hipMemcpyDtoD
  4. hipMemcpyHtoH
- Added test for added apis

Change-Id: I4a9c382445b62631f8d0bcbb9a670322288b72b1


[ROCm/hip commit: 4152746e26]
2016-08-26 13:11:01 -05:00

27 righe
532 B
C++

#include<iostream>
#include<hip/hip_runtime.h>
#include<hip/hip_runtime_api.h>
#define LEN 1024
#define SIZE LEN<<2
int main(){
int *A, *B, *C;
hipDeviceptr 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;
}
}