9043ba55db
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
[ROCm/hip commit: efb9b9e86c]
63 satır
2.0 KiB
C++
63 satır
2.0 KiB
C++
/*
|
|
Copyright (c) 2015-2017 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 ../test_common.cpp
|
|
* RUN: %t EXCLUDE_HIP_PLATFORM nvcc
|
|
* HIT_END
|
|
*/
|
|
|
|
#include "hip/hip_runtime.h"
|
|
#include "test_common.h"
|
|
|
|
#define LEN 8*1024
|
|
#define SIZE LEN*4
|
|
|
|
__global__ void vectorAdd(hipLaunchParm lp, float *Ad, float *Bd) {
|
|
HIP_DYNAMIC_SHARED(float, sBd);
|
|
int tx = hipThreadIdx_x;
|
|
for(int i=0;i<LEN/64;i++) {
|
|
sBd[tx + i * 64] = Ad[tx + i * 64] + 1.0f;
|
|
Bd[tx + i * 64] = sBd[tx + i * 64];
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
float *A, *B, *Ad, *Bd;
|
|
A = new float[LEN];
|
|
B = new float[LEN];
|
|
for(int i=0;i<LEN;i++) {
|
|
A[i] = 1.0f;
|
|
B[i] = 1.0f;
|
|
}
|
|
hipMalloc(&Ad, SIZE);
|
|
hipMalloc(&Bd, SIZE);
|
|
hipMemcpy(Ad, A, SIZE, hipMemcpyHostToDevice);
|
|
hipMemcpy(Bd, B, SIZE, hipMemcpyHostToDevice);
|
|
hipLaunchKernel(vectorAdd, dim3(1,1,1), dim3(64,1,1), SIZE, 0, Ad, Bd);
|
|
hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost);
|
|
for(int i=0;i<LEN;i++) {
|
|
assert(B[i] > 1.0f && B[i] < 3.0f);
|
|
}
|
|
passed();
|
|
}
|