changed __global__ attribute

1. Moved around tests and added them to HIT

Change-Id: I5d75280c42a5af852670ebabc7305ee56721ec7b


[ROCm/hip commit: 5e3d63c0a3]
这个提交包含在:
Aditya Atluri 于 2017-02-03 10:53:36 -06:00 提交
1 父节点 afb38e15de
当前提交 6d5992d445
52 个文件已更改
+316 -411

没有与搜索条件相匹配的文件

@@ -0,0 +1,53 @@
/*
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <iostream>
#include "hip/hip_runtime.h"
#include "hip/hip_runtime_api.h"
#include "hip/hcc_detail/hip_complex.h"
#define LEN 64
#define SIZE 64<<2
__global__ void getSqAbs(hipLaunchParm lp, float *A, float *B, float *C){
int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x;
C[tx] = hipCsqabsf(make_hipFloatComplex(A[tx], B[tx]));
}
int main(){
float *A, *Ad, *B, *Bd, *C, *Cd;
A = new float[LEN];
B = new float[LEN];
C = new float[LEN];
for(uint32_t i=0;i<LEN;i++){
A[i] = i*1.0f;
B[i] = i*1.0f;
C[i] = i*1.0f;
}
hipMalloc((void**)&Ad, SIZE);
hipMalloc((void**)&Bd, SIZE);
hipMalloc((void**)&Cd, SIZE);
hipMemcpy(Ad, A, SIZE, hipMemcpyHostToDevice);
hipMemcpy(Bd, B, SIZE, hipMemcpyHostToDevice);
hipLaunchKernel(getSqAbs, dim3(1), dim3(LEN), 0, 0, Ad, Bd, Cd);
hipMemcpy(C, Cd, SIZE, hipMemcpyDeviceToHost);
std::cout<<A[11]<<" "<<B[11]<<" "<<C[11]<<std::endl;
}
@@ -0,0 +1,42 @@
#include<iostream>
#include "hip/hip_runtime.h"
#include "hip/hip_runtime_api.h"
#define LEN 1030
#define SIZE LEN << 2
__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In, uint32_t *Vald)
{
memcpy(Out, In, SIZE, Vald);
}
__global__ void set(hipLaunchParm lp, uint32_t *ptr, uint8_t val, size_t size)
{
memset(ptr, val, size);
}
int main()
{
uint32_t *A, *Ad, *B, *Bd;
uint32_t *Val, *Vald;
A = new uint32_t[LEN];
B = new uint32_t[LEN];
Val = new uint32_t;
*Val = 0;
for(int i=0;i<LEN;i++){
A[i] = i *1.0f;
B[i] = 0.0f;
}
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);
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;
}
std::cout<<*Val<<std::endl;
}
+28 -104
查看文件
@@ -1,16 +1,13 @@
/*
Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved.
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,113 +17,40 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* HIT_START
* BUILD: %t %s ../test_common.cpp
* RUN: %t
* HIT_END
*/
#include "test_common.h"
#include "hip/hip_runtime.h"
#include <stdio.h>
#include <hip/hip_fp16.h>
#include "hip/hip_runtime_api.h"
#include "hip/hip_fp16.h"
#define hInf 0x7C00
#define hInfPK 0x7C007C00
#define h65504 0xF7FF
#define h65504PK 0xF7FFF7FF
#define h27 0x4EC0
#define h27PK 0x4EC04EC0
#define h7 0x4700
#define h7PK 0x47004700
#define h3 0x4200
#define h3PK 0x42004200
#define h1 0x3C00
#define h1PK 0x3C003C00
#define hPoint5 0x3800
#define hPoint5PK 0x38003800
#define hZero 0x0000
#define hNeg1 0xBC00
#define hNeg1PK 0xBC00BC00
#define DSIZE 4
#define SCF 0.5f
#define nTPB 256
__global__ void half_scale_kernel(hipLaunchParm lp, float *din, float *dout, int dsize){
__global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In3, __half* Out){
Out[0] = __hadd(In1[0], In2[0]);
Out[1] = __hadd_sat(In1[1], In2[1]);
Out[2] = __hfma(In1[2], In2[2],In3[2]);
Out[3] = __hfma_sat(In1[3], In2[3], In3[3]);
Out[4] = __hmul(In1[4], In2[4]);
Out[5] = __hmul_sat(In1[5], In2[5]);
Out[6] = __hneg(In1[6]);
Out[7] = __hsub(In1[7], In2[7]);
Out[8] = __hsub_sat(In1[8], In2[8]);
Out[9] = hdiv(In1[9], In2[9]);
Out[10] = hceil(In1[10]);
Out[11] = hcos(In1[11]);
Out[12] = hexp(In1[12]);
Out[13] = hexp10(In1[13]);
Out[14] = hexp2(In1[14]);
Out[15] = hfloor(In1[15]);
Out[16] = hlog(In1[16]);
Out[17] = hlog10(In1[17]);
Out[18] = hlog2(In1[18]);
// Out[19] = hrcp(In1[19]);
Out[20] = hrint(In1[20]);
Out[21] = hrsqrt(In1[21]);
Out[22] = hsin(In1[22]);
Out[23] = hsqrt(In1[23]);
Out[24] = htrunc(In1[24]);
}
int idx = hipThreadIdx_x+ hipBlockDim_x*hipBlockIdx_x;
if (idx < dsize){
__half scf = __float2half(SCF);
__half kin = __float2half(din[idx]);
__half kout;
__global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* In3, __half2* Out){
Out[0] = __hadd2(In1[0], In2[0]);
Out[1] = __hadd2_sat(In1[1], In2[1]);
Out[2] = __hfma2(In1[2], In2[2],In3[2]);
Out[3] = __hfma2_sat(In1[3], In2[3], In3[3]);
Out[4] = __hmul2(In1[4], In2[4]);
Out[5] = __hmul2_sat(In1[5], In2[5]);
Out[6] = __hneg2(In1[6]);
Out[7] = __hsub2(In1[7], In2[7]);
Out[8] = __hsub2_sat(In1[8], In2[8]);
Out[9] = h2div(In1[9], In2[9]);
Out[10] = h2ceil(In1[10]);
Out[11] = h2cos(In1[11]);
Out[12] = h2exp(In1[12]);
Out[13] = h2exp10(In1[13]);
Out[14] = h2exp2(In1[14]);
Out[15] = h2floor(In1[15]);
Out[16] = h2log(In1[16]);
Out[17] = h2log10(In1[17]);
Out[18] = h2log2(In1[18]);
Out[19] = h2rcp(In1[19]);
// Out[20] = h2rint(In1[20]);
Out[21] = h2rsqrt(In1[21]);
Out[22] = h2sin(In1[22]);
Out[23] = h2sqrt(In1[23]);
Out[24] = h2trunc(In1[24]);
}
kout = __hmul(kin, scf);
__global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) {
Out[0] = __heq(In1[0], In2[0]);
Out[1] = __hge(In1[1], In2[1]);
Out[2] = __hgt(In1[2], In2[2]);
Out[3] = __hisinf(In1[3]);
Out[4] = __hisnan(In1[4]);
Out[5] = __hle(In1[5], In2[5]);
Out[6] = __hlt(In1[6], In2[6]);
Out[7] = __hne(In1[7], In2[7]);
}
__global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* Out) {
Out[0] = __heq2(In1[0], In2[0]);
Out[1] = __hge2(In1[1], In2[1]);
Out[2] = __hgt2(In1[2], In2[2]);
Out[4] = __hisnan2(In1[4]);
Out[5] = __hle2(In1[5], In2[5]);
Out[6] = __hlt2(In1[6], In2[6]);
Out[7] = __hne2(In1[7], In2[7]);
// kout = cvt_float_to_half(cvt_half_to_float(kin)*cvt_half_to_float(scf));
dout[idx] = __half2float(kout);
}
}
int main(){
passed();
float *hin, *hout, *din, *dout;
hin = (float *)malloc(DSIZE*sizeof(float));
hout = (float *)malloc(DSIZE*sizeof(float));
for (int i = 0; i < DSIZE; i++) hin[i] = i;
hipMalloc(&din, DSIZE*sizeof(float));
hipMalloc(&dout, DSIZE*sizeof(float));
hipMemcpy(din, hin, DSIZE*sizeof(float), hipMemcpyHostToDevice);
hipLaunchKernel(half_scale_kernel, dim3((DSIZE+nTPB-1)/nTPB),dim3(nTPB), 0, 0, din, dout, DSIZE);
hipMemcpy(hout, dout, DSIZE*sizeof(float), hipMemcpyDeviceToHost);
for (int i = 0; i < DSIZE; i++) printf("%f\n", hout[i]);
return 0;
}
@@ -0,0 +1,431 @@
/*
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "test_common.h"
#include <iostream>
#include "hip/hip_runtime.h"
#include "hip/hip_runtime_api.h"
#define N 512
bool check_erfcinvf(){
uint32_t len = 4;
float Val[] = {0.1, 1.2, 1, 0.9};
float Out[] = {1.16309, -0.179144, 0, 0.0889};
for(int i=0;i<len;i++){
if(Out[i] - erfcinvf(Val[i]) > 0.0001)
{
return false;
}
}
return true;
}
bool check_erfcxf(){
uint32_t len = 4;
float Val[] = {-0.5, 15, 3.2, 1};
float Out[] = {1.9524, 0.0375, 0.1687, 0.4276};
for(int i=0;i<len;i++){
if(Out[i] - erfcxf(Val[i]) > 0.0001)
{
return false;
}
}
return true;
}
bool check_erfinvf()
{
uint32_t len = 4;
float Val[] = {0, -0.5, 0.9, -0.2};
float Out[] = {0, -0.4769, 1.1631, -0.1791};
for(int i=0;i<len;i++){
if(Out[i] - erfinvf(Val[i]) > 0.0001){
return false;
}
}
return true;
}
bool check_fdividef()
{
uint32_t len = 4;
float Val[] = {0, -0.5, 0.9, -0.2};
float Out[] = {1, -0.4769, 1.1631, -0.1791};
for(int i=0;i<len;i++){
if(Val[i]/Out[i] - fdividef(Val[i], Out[i]) > 0.0001){
return false;
}
}
return true;
}
bool check_erfcinv(){
uint32_t len = 4;
double Val[] = {0.1, 1.2, 1, 0.9};
double Out[] = {1.16309, -0.179144, 0, 0.0889};
for(int i=0;i<len;i++){
if(Out[i] - erfcinv(Val[i]) > 0.0001)
{
return false;
}
}
return true;
}
bool check_erfcx(){
uint32_t len = 4;
double Val[] = {-0.5, 15, 3.2, 1};
double Out[] = {1.9524, 0.0375, 0.1687, 0.4276};
for(int i=0;i<len;i++){
if(Out[i] - erfcx(Val[i]) > 0.0001)
{
return false;
}
}
return true;
}
bool check_erfinv()
{
uint32_t len = 4;
double Val[] = {0, -0.5, 0.9, -0.2};
double Out[] = {0, -0.4769, 1.1631, -0.1791};
for(int i=0;i<len;i++){
if(Out[i] - erfinv(Val[i]) > 0.0001){
return false;
}
}
return true;
}
bool check_fdivide()
{
uint32_t len = 4;
double Val[] = {0, -0.5, 0.9, -0.2};
double Out[] = {1, -0.4769, 1.1631, -0.1791};
for(int i=0;i<len;i++){
if(Val[i]/Out[i] - fdivide(Val[i], Out[i]) > 0.0001){
return false;
}
}
return true;
}
bool check_modff()
{
uint32_t len = 4;
float Val[] = {0, -0.5, 0.9, -0.2};
float iPtr[] = {0, 0, 0, 0};
float frac[] = {0, -0.5, 0.9, -0.2};
float Out[] = {1, 1, 1, 1};
for(int i=0;i<len;i++){
if(frac[i] - modff(Val[i], Out+i) > 0.0001 && iPtr[i] == Out[i]){
return false;
}
}
return true;
}
bool check_modf()
{
uint32_t len = 4;
double Val[] = {0, -0.5, 0.9, -0.2};
double iPtr[] = {0, 0, 0, 0};
double frac[] = {0, -0.5, 0.9, -0.2};
double Out[] = {1, 1, 1, 1};
for(int i=0;i<len;i++){
if(frac[i] - modf(Val[i], Out+i) > 0.0001 && iPtr[i] == Out[i]){
return false;
}
}
return true;
}
bool check_nextafterf()
{
uint32_t len = 4;
float Val[] = {0, -0.5, 0.9, -0.2};
float iPtr[] = {0, 0, 0, 0};
float frac[] = {0, -0.5, 0.9, -0.2};
float Out[] = {1, 1, 1, 1};
for(int i=0;i<len;i++){
if(nextafterf(Val[i],1) - Val[i] > 0.0001){
return false;
}
}
return true;
}
bool check_nextafter()
{
uint32_t len = 4;
double Val[] = {0, -0.5, 0.9, -0.2};
double iPtr[] = {0, 0, 0, 0};
double frac[] = {0, -0.5, 0.9, -0.2};
double Out[] = {1, 1, 1, 1};
for(int i=0;i<len;i++){
if(nextafter(Val[i],1) - Val[i] > 0.0001){
return false;
}
}
return true;
}
bool check_norm3df(float *A)
{
float f = norm3df(A[0], A[1], A[2]);
float out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2]);
if(f - out > 0.0001)
{
return false;
}
return true;
}
bool check_norm3d(double *A)
{
double f = norm3d(A[0], A[1], A[2]);
double out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2]);
if(f - out > 0.0001)
{
return false;
}
return true;
}
bool check_norm4df(float *A)
{
float f = norm4df(A[0], A[1], A[2], A[3]);
float out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2] + A[3]*A[3]);
if(f - out > 0.0001)
{
return false;
}
return true;
}
bool check_norm4d(double *A)
{
double f = norm4d(A[0], A[1], A[2], A[3]);
double out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2] + A[3]*A[3]);
if(f - out > 0.0001)
{
return false;
}
return true;
}
bool check_normcdff(){
uint32_t len = 2;
float Val[] = {0,1};
float Out[] = {0.5, 0.8413};
for(int i=0;i<len;i++){
if(Out[i] - normcdff(Val[i]) > 0.0001)
{
return false;
}
}
return true;
}
bool check_normcdf(){
uint32_t len = 2;
float Val[] = {0,1};
float Out[] = {0.5, 0.8413};
for(int i=0;i<len;i++){
if(Out[i] - normcdf(Val[i]) > 0.0001)
{
return false;
}
}
return true;
}
bool check_normcdfinvf(){
uint32_t len = 2;
double Val[] = {0.5, 0.8413};
for(int i=0;i<len;i++){
if(Val[i] - normcdfinvf(normcdff(Val[i])) > 0.0001)
{
return false;
}
}
return true;
}
bool check_normcdfinv(){
uint32_t len = 2;
double Val[] = {0.5, 0.8413};
for(int i=0;i<len;i++){
if(Val[i] - normcdfinv(normcdf(Val[i])) > 0.0001)
{
return false;
}
}
return true;
}
bool check_rcbrtf()
{
float f = 1.0f;
if(rcbrtf(f) != 1.0f)
{
return false;
}
return true;
}
bool check_rcbrt()
{
double f = 1.0;
if(rcbrt(f) != 1.0)
{
return false;
}
return true;
}
bool check_rhypotf()
{
float f = 1.0f;
float g = 2.0f;
float val = rhypotf(f, g);
float sq = f*f + g*g ;
if(1/(val*val) - sq > 0.0001)
{
return false;
}
return true;
}
bool check_rhypot()
{
double f = 1.0f;
double g = 2.0f;
double val = rhypot(f, g);
double sq = f*f + g*g;
if(1/(val*val) - sq > 0.0001)
{
return false;
}
return true;
}
bool check_rnorm3df(float *A)
{
float f = rnorm3df(A[0], A[1], A[2]);
float out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2]);
if(f - 1/out > 0.0001)
{
return false;
}
return true;
}
bool check_rnorm3d(double *A)
{
double f = rnorm3d(A[0], A[1], A[2]);
double out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2]);
if(f - 1/out > 0.0001)
{
return false;
}
return true;
}
bool check_rnorm4df(float *A)
{
float f = rnorm4df(A[0], A[1], A[2], A[3]);
float out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2] + A[3]*A[3]);
if(f - 1/out > 0.0001)
{
return false;
}
return true;
}
bool check_rnorm4d(double *A)
{
double f = rnorm4d(A[0], A[1], A[2], A[3]);
double out = sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2] + A[3]*A[3]);
if(f - 1/out > 0.0001)
{
return false;
}
return true;
}
bool check_rnormf(float *A)
{
return (rnorm3df(A[0],A[1],A[2]) - rnormf(3,A) < 0.0001) && (rnorm4df(A[0],A[1],A[2],A[3]) - rnormf(4, A) < 0.0001 );
}
bool check_rnorm(double *A)
{
return (rnorm3d(A[0],A[1],A[2]) - rnorm(3,A) < 0.0001) && (rnorm4d(A[0],A[1],A[2],A[3]) - rnorm(4, A) < 0.0001 );
}
bool check_sincospif()
{
float s1, c1, s2, c2;
float in1 = 1, in2 = 0.5;
sincospif(in1, &s1, &c1);
sincospif(in2, &s2, &c2);
if( (s1 - 0 < 0.00001) && (s2 - 1 < 0.00001) && (c1 + 1 < 0.00001) && (c2 - 0 < 0.00001)){
return true;
}
return false;
}
bool check_sincospi()
{
double s1, c1, s2, c2;
double in1 = 1, in2 = 0.5;
sincospi(in1, &s1, &c1);
sincospi(in2, &s2, &c2);
if( (s1 - 0 < 0.00001) && (s2 - 1 < 0.00001) && (c1 + 1 < 0.00001) && (c2 - 0 < 0.00001)){
return true;
}
return false;
}
int main(){
float *Af = new float[N];
double *A = new double[N];
for(int i=0;i<N;i++){
Af[i] = i * 1.0f;
A[i] = i * 1.0;
}
if(check_erfcinvf() && check_erfcxf() && check_erfcinvf() &&
check_erfcinv() && check_erfcx() && check_erfcinv() &&
check_fdividef() && check_fdivide() && check_modff() &&
check_modf() && check_nextafterf() && check_norm3df(Af) &&
check_norm3d(A) && check_norm4df(Af) && check_norm4d(A) &&
check_normcdff() && check_normcdf() && check_normcdfinvf() &&
check_normcdfinv() && check_rcbrtf() && check_rcbrt() &&
check_rhypotf() && check_rhypot() && check_rnorm3df(Af) &&
check_rnorm3d(A) && check_rnorm4df(Af) && check_rnorm4d(A) &&
check_rnormf(Af) && check_rnorm(A) && check_sincospif() &&
check_sincospi()
){
passed();
}
}