Files
rocm-systems/tests/src/hipC.c
T

26 lines
672 B
C
Raw Normal View History

2016-03-25 13:45:28 -05:00
#include"hip_runtime.h"
#include<stdio.h>
#define ITER 1<<20
#define SIZE 1024*1024*sizeof(int)
2016-04-11 13:01:02 -05:00
2016-03-25 13:45:28 -05:00
__global__ void Iter(hipLaunchParm lp, int *Ad){
int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x;
if(tx == 0){
for(int i=0;i<ITER;i++){
Ad[tx] += 1;
}
}
}
2016-04-11 13:01:02 -05:00
2016-03-25 13:45:28 -05:00
int main(){
int A=0, *Ad;
hipMalloc((void**)&Ad, SIZE);
hipMemcpy(Ad, &A, SIZE, hipMemcpyHostToDevice);
2016-04-11 13:01:02 -05:00
dim3 dimGrid, dimBlock;
dimGrid.x = 1, dimGrid.y =1, dimGrid.z = 1;
dimBlock.x = 1, dimBlock.y = 1, dimGrid.z = 1;
hipLaunchKernel(HIP_KERNEL_NAME(Iter), dimGrid, dimBlock, 0, 0, Ad);
2016-03-25 13:45:28 -05:00
hipMemcpy(&A, Ad, SIZE, hipMemcpyDeviceToHost);
}