Merge branch 'amd-develop' into amd-master

Change-Id: I53d5a8916d769c4f0fe60d2ee3b240551da80b4f
(cherry picked from commit 01c523f6c9)
Этот коммит содержится в:
Maneesh Gupta
2017-04-07 15:40:09 +05:30
коммит произвёл Maneesh Gupta
родитель 5366c23fea
Коммит bb8c51a129
23 изменённых файлов: 451 добавлений и 214 удалений
+33 -12
Просмотреть файл
@@ -1,18 +1,29 @@
#include<iostream>
#include <iostream>
#include "hip/hip_runtime.h"
#include "hip/hip_runtime_api.h"
#include "../test_common.h"
#define LEN 1030
#define SIZE LEN << 2
__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In, uint32_t *Vald)
/* HIT_START
* BUILD: %t %s ../test_common.cpp
* RUN: %t
* HIT_END
*/
__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In)
{
memcpy(Out, In, SIZE, Vald);
int tx = hipThreadIdx_x;
memcpy(Out + tx, In + tx, SIZE/LEN);
}
__global__ void set(hipLaunchParm lp, uint32_t *ptr, uint8_t val, size_t size)
{
memset(ptr, val, size);
int tx = hipThreadIdx_x;
memset(ptr + tx, val, size);
}
int main()
@@ -24,19 +35,29 @@ int main()
Val = new uint32_t;
*Val = 0;
for(int i=0;i<LEN;i++){
A[i] = i *1.0f;
B[i] = 0.0f;
A[i] = i;
B[i] = 0;
}
hipMalloc((void**)&Ad, SIZE);
hipMalloc((void**)&Bd, SIZE);
hipMalloc((void**)&Vald, sizeof(uint32_t));
hipMemcpy(Ad, A, SIZE, hipMemcpyHostToDevice);
hipLaunchKernel(cpy, dim3(1), dim3(LEN/4), 0, 0, Bd, Ad, Vald);
hipLaunchKernel(set, dim3(1), dim3(LEN/4), 0, 0, Bd, 0x1, SIZE);
hipLaunchKernel(cpy, dim3(1), dim3(LEN), 0, 0, Bd, Ad);
hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost);
hipMemcpy(Val, Vald, sizeof(uint32_t), hipMemcpyDeviceToHost);
for(int i=LEN-16;i<LEN;i++){
std::cout<<A[i]<<" "<<B[i]<<std::endl;
if(A[i]!=B[i]){
return 0;
}
}
std::cout<<*Val<<std::endl;
hipLaunchKernel(set, dim3(1), dim3(LEN), 0, 0, Bd, 0x1, LEN);
hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost);
for(int i=LEN-16;i<LEN;i++){
if(0x01010101!=B[i]){
return 0;
}
}
passed();
}