Apply .clangformat to all repo source files

Change-Id: I7e79c6058f0303f9a98911e3b7dd2e8596079344


[ROCm/hip commit: 1ba06f63c4]
This commit is contained in:
Maneesh Gupta
2018-03-12 11:29:03 +05:30
parent 52506ef382
commit 4f42ee762d
293 changed files with 43980 additions and 45830 deletions
@@ -20,22 +20,19 @@ THE SOFTWARE.
#include <iostream>
#include <hip/hip_runtime.h>
#define WIDTH 32
#define WIDTH 32
#define NUM (WIDTH*WIDTH)
#define NUM (WIDTH * WIDTH)
#define THREADS_PER_BLOCK_X 4
#define THREADS_PER_BLOCK_Y 4
#define THREADS_PER_BLOCK_Z 1
#define THREADS_PER_BLOCK_X 4
#define THREADS_PER_BLOCK_Y 4
#define THREADS_PER_BLOCK_Z 1
using namespace std;
__global__ void matrixTranspose_static_shared(hipLaunchParm lp,
float *out,
float *in,
const int width)
{
__shared__ float sharedMem[WIDTH*WIDTH];
__global__ void matrixTranspose_static_shared(hipLaunchParm lp, float* out, float* in,
const int width) {
__shared__ float sharedMem[WIDTH * WIDTH];
int x = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x;
int y = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y;
@@ -47,11 +44,8 @@ __global__ void matrixTranspose_static_shared(hipLaunchParm lp,
out[y * width + x] = sharedMem[y * width + x];
}
__global__ void matrixTranspose_dynamic_shared(hipLaunchParm lp,
float *out,
float *in,
const int width)
{
__global__ void matrixTranspose_dynamic_shared(hipLaunchParm lp, float* out, float* in,
const int width) {
// declare dynamic shared memory
HIP_DYNAMIC_SHARED(float, sharedMem)
@@ -65,39 +59,34 @@ __global__ void matrixTranspose_dynamic_shared(hipLaunchParm lp,
out[y * width + x] = sharedMem[y * width + x];
}
void MultipleStream (float **data, float *randArray, float **gpuTransposeMatrix, float **TransposeMatrix, int width)
{
void MultipleStream(float** data, float* randArray, float** gpuTransposeMatrix,
float** TransposeMatrix, int width) {
const int num_streams = 2;
hipStream_t streams[num_streams];
for(int i=0;i<num_streams;i++)
hipStreamCreate(&streams[i]);
for (int i = 0; i < num_streams; i++) hipStreamCreate(&streams[i]);
for(int i=0;i<num_streams;i++)
{
for (int i = 0; i < num_streams; i++) {
hipMalloc((void**)&data[i], NUM * sizeof(float));
hipMemcpyAsync(data[i], randArray, NUM * sizeof(float), hipMemcpyHostToDevice,streams[i]);
hipMemcpyAsync(data[i], randArray, NUM * sizeof(float), hipMemcpyHostToDevice, streams[i]);
}
hipLaunchKernel(matrixTranspose_static_shared,
dim3(WIDTH/THREADS_PER_BLOCK_X, WIDTH/THREADS_PER_BLOCK_Y),
dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y),
0, streams[0],
dim3(WIDTH / THREADS_PER_BLOCK_X, WIDTH / THREADS_PER_BLOCK_Y),
dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y), 0, streams[0],
gpuTransposeMatrix[0], data[0], width);
hipLaunchKernel(matrixTranspose_dynamic_shared,
dim3(WIDTH/THREADS_PER_BLOCK_X, WIDTH/THREADS_PER_BLOCK_Y),
dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y),
sizeof(float)*WIDTH*WIDTH, streams[1],
gpuTransposeMatrix[1], data[1], width);
for(int i=0;i<num_streams;i++)
hipMemcpyAsync(TransposeMatrix[i], gpuTransposeMatrix[i], NUM*sizeof(float), hipMemcpyDeviceToHost, streams[i]);
dim3(WIDTH / THREADS_PER_BLOCK_X, WIDTH / THREADS_PER_BLOCK_Y),
dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y), sizeof(float) * WIDTH * WIDTH,
streams[1], gpuTransposeMatrix[1], data[1], width);
for (int i = 0; i < num_streams; i++)
hipMemcpyAsync(TransposeMatrix[i], gpuTransposeMatrix[i], NUM * sizeof(float),
hipMemcpyDeviceToHost, streams[i]);
}
int main(){
int main() {
hipSetDevice(0);
float *data[2], *TransposeMatrix[2], *gpuTransposeMatrix[2], *randArray;
@@ -112,9 +101,8 @@ int main(){
hipMalloc((void**)&gpuTransposeMatrix[0], NUM * sizeof(float));
hipMalloc((void**)&gpuTransposeMatrix[1], NUM * sizeof(float));
for(int i = 0; i < NUM; i++)
{
randArray[i] = (float)i*1.0f;
for (int i = 0; i < NUM; i++) {
randArray[i] = (float)i * 1.0f;
}
MultipleStream(data, randArray, gpuTransposeMatrix, TransposeMatrix, width);
@@ -125,22 +113,22 @@ int main(){
int errors = 0;
double eps = 1.0E-6;
for (int i = 0; i < NUM; i++) {
if (std::abs(TransposeMatrix[0][i] - TransposeMatrix[1][i]) > eps ) {
printf("%d stream0: %f stream1 %f\n",i,TransposeMatrix[0][i],TransposeMatrix[1][i]);
errors++;
if (std::abs(TransposeMatrix[0][i] - TransposeMatrix[1][i]) > eps) {
printf("%d stream0: %f stream1 %f\n", i, TransposeMatrix[0][i], TransposeMatrix[1][i]);
errors++;
}
}
if (errors!=0) {
printf("FAILED: %d errors\n",errors);
if (errors != 0) {
printf("FAILED: %d errors\n", errors);
} else {
printf ("stream PASSED!\n");
printf("stream PASSED!\n");
}
free(randArray);
for(int i=0;i<2;i++){
hipFree(data[i]);
hipFree(gpuTransposeMatrix[i]);
free(TransposeMatrix[i]);
for (int i = 0; i < 2; i++) {
hipFree(data[i]);
hipFree(gpuTransposeMatrix[i]);
free(TransposeMatrix[i]);
}
hipDeviceReset();