added __host__ for complex functions and corrected memset and memcpy test

Change-Id: I9ffefb7a0025aa111a54d20d2766982df15532e7


[ROCm/hip commit: 6dff2714e9]
This commit is contained in:
Aditya Atluri
2017-04-06 09:29:44 -05:00
والد 72238e2119
کامیت 26f6ce992d
2فایلهای تغییر یافته به همراه58 افزوده شده و 37 حذف شده
@@ -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();
}