0005dd5f66
Squashed commit of the following: commit c111b5bd10d7c2a5b0b1ad8b07f6e81185b47b39 Author: Wen-Heng (Jack) Chung <whchung@gmail.com> Date: Sat Mar 4 17:06:46 2017 +0800 Use __device__ for all variables and functions to be used in kernel path Abolish __device and adopt [[hc]] in HIP implementation, so __device__ can be used on all HIP applications, no matter they are variables or functions. Change-Id: I20ca25857ce3bc3e42a5ebf65cafea2c8492f4c7 commit 30c0e4e4701bbf6bd9a7182e0320a71ff73d3a83 Author: Wen-Heng (Jack) Chung <whchung@gmail.com> Date: Thu Mar 2 12:14:11 2017 +0800 XXX FIXME get around LDS spills caused in Promote-free HCC hipDynamicShared2 uses all 64KB of LDS for computation. But in Promote-free HCC there are cases where LDS spills would occur, which would make the test case to hang. In this workaround commit we reduce the size of dynamic LDS used to get around this known issue, and will revert this commit when LDS spills are resolved in HCC. Change-Id: If648b36200a4f9143951a8129192bcb7ed0bef5e commit e803173be2d73e2f132a7ff7f61e7a20b4083d34 Author: Wen-Heng (Jack) Chung <whchung@gmail.com> Date: Wed Mar 1 21:41:41 2017 +0800 Fix math functions which take pointer arguments Change-Id: I332c997e640edbc44824691e2a9434c6b3dadefa commit de590c469e213c42090ff83dbd060f25bb1d6047 Author: Wen-Heng (Jack) Chung <whchung@gmail.com> Date: Wed Mar 1 18:38:54 2017 +0800 Changes to cope with Promote-free HCC - abolish usage of address_space GNU attribute - use __device in file-scope global variables which would be accessed by GPU kernels - temporarily disable some math functions which take pointer arguments Change-Id: I730311dee848e20e763e35cd3980317fce0dce0d Change-Id: I1f6b970b53b9401eeaaab08f04a7b9fed0fb8cf0
93 baris
2.9 KiB
C++
93 baris
2.9 KiB
C++
/*
|
|
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.
|
|
*/
|
|
|
|
/* HIT_START
|
|
* BUILD: %t %s EXCLUDE_HIP_PLATFORM nvcc
|
|
* RUN: %t
|
|
* HIT_END
|
|
*/
|
|
|
|
#include<hip/hip_runtime.h>
|
|
#include<hip/hip_runtime_api.h>
|
|
#include"test_common.h"
|
|
#include<iostream>
|
|
|
|
#define NUM 1024
|
|
#define SIZE 1024*4
|
|
|
|
__device__ int globalIn[NUM];
|
|
__device__ int globalOut[NUM];
|
|
|
|
__global__ void Assign(hipLaunchParm lp, int* Out)
|
|
{
|
|
int tid = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x;
|
|
Out[tid] = globalIn[tid];
|
|
globalOut[tid] = globalIn[tid];
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int *A, *Am, *B, *Ad, *C, *Cm;
|
|
A = new int[NUM];
|
|
B = new int[NUM];
|
|
C = new int[NUM];
|
|
for(unsigned i=0;i<NUM;i++) {
|
|
A[i] = -1*i;
|
|
B[i] = 0;
|
|
C[i] = 0;
|
|
}
|
|
|
|
hipMalloc((void**)&Ad, SIZE);
|
|
hipHostMalloc((void**)&Am, SIZE);
|
|
hipHostMalloc((void**)&Cm, SIZE);
|
|
for(unsigned i=0;i<NUM;i++) {
|
|
Am[i] = -1*i;
|
|
Cm[i] = 0;
|
|
}
|
|
|
|
hipStream_t stream;
|
|
hipStreamCreate(&stream);
|
|
hipMemcpyToSymbolAsync(HIP_SYMBOL(globalIn), Am, SIZE, 0, hipMemcpyHostToDevice, stream);
|
|
hipStreamSynchronize(stream);
|
|
hipLaunchKernel(Assign, dim3(1,1,1), dim3(NUM,1,1), 0, 0, Ad);
|
|
hipMemcpy(B, Ad, SIZE, hipMemcpyDeviceToHost);
|
|
hipMemcpyFromSymbolAsync(Cm, HIP_SYMBOL(globalOut), SIZE, 0, hipMemcpyDeviceToHost, stream);
|
|
hipStreamSynchronize(stream);
|
|
for(unsigned i=0;i<NUM;i++) {
|
|
assert(Am[i] == B[i]);
|
|
assert(Am[i] == Cm[i]);
|
|
}
|
|
|
|
for(unsigned i=0;i<NUM;i++) {
|
|
A[i] = -2*i;
|
|
B[i] = 0;
|
|
}
|
|
|
|
hipMemcpyToSymbol(HIP_SYMBOL(globalIn), A, SIZE, 0, hipMemcpyHostToDevice);
|
|
hipLaunchKernel(Assign, dim3(1,1,1), dim3(NUM,1,1), 0, 0, Ad);
|
|
hipMemcpy(B, Ad, SIZE, hipMemcpyDeviceToHost);
|
|
hipMemcpyFromSymbol(C, HIP_SYMBOL(globalOut), SIZE, 0, hipMemcpyDeviceToHost);
|
|
for(unsigned i=0;i<NUM;i++) {
|
|
assert(A[i] == B[i]);
|
|
// assert(A[i] == C[i]);
|
|
}
|
|
|
|
passed();
|
|
}
|