Surgeon Simulator 2013는 이미 있는데 해보지 않았고.. 지인에게나 줘버려야지 ㅋㅋㅋ
'게임 > 오리진&스팀&유플레이' 카테고리의 다른 글
| MDK 할인! (0) | 2014.03.19 |
|---|---|
| 몰라 걍 질러 (0) | 2014.03.10 |
| 간만에 게임 목록 (0) | 2013.12.29 |
| 스팀 연말 할인 시작!! (0) | 2013.12.22 |
| 리눅스 스팀 설치! (0) | 2013.12.17 |
| MDK 할인! (0) | 2014.03.19 |
|---|---|
| 몰라 걍 질러 (0) | 2014.03.10 |
| 간만에 게임 목록 (0) | 2013.12.29 |
| 스팀 연말 할인 시작!! (0) | 2013.12.22 |
| 리눅스 스팀 설치! (0) | 2013.12.17 |
| 백수.. 5주.. 차? (0) | 2014.01.23 |
|---|---|
| ㅋㅋㅋㅋㅋ 국민카드 ㅋㅋㅋㅋㅋㅋ 시발 ㅋㅋㅋㅋㅋ (0) | 2014.01.19 |
| 아이매직 BW-1430 블루투스/USB 겸용 풀 사이즈 키보드 (0) | 2014.01.06 |
| 새해 복 많이 받으세요! (4) | 2014.01.01 |
| 수영강습을 신청하였다. (0) | 2013.12.31 |
#include < stdio.h >
#include < stdlib.h >
#include < time.h >
#include "cuda_runtime.h"
#define BLOCK_WID 128
#define THREAD_WID 32
#define ARRAY_SIZE (THREAD_WID * THREAD_WID * BLOCK_WID * BLOCK_WID)
__global__ void kernel_test(int *a, int *b, int *c)
{
int idx = threadIdx.x +blockIdx.x * blockDim.x + (gridDim.x * blockDim.x) * (blockIdx.y * blockDim.y + threadIdx.y);
c[idx] = a[idx] + b[idx];
}
void main()
{
clock_t start_time, end_time;
int *a, *b, *c, *res;
int *dev_a,*dev_b,*dev_c;
unsigned int idx = 0;
dim3 block(BLOCK_WID,BLOCK_WID);
dim3 thread(THREAD_WID,THREAD_WID);
a = (int *)malloc(ARRAY_SIZE * sizeof(int));
b = (int *)malloc(ARRAY_SIZE * sizeof(int));
c = (int *)malloc(ARRAY_SIZE * sizeof(int));
res = (int *)malloc(ARRAY_SIZE * sizeof(int));
// initialize
srand (time(NULL));
for(idx = 0;idx < ARRAY_SIZE ; idx++)
{
a[idx] = rand() & 0xFFFF;
b[idx] = rand() & 0xFFFF;
c[idx] = 0;
}
start_time = clock();
for(idx = 0;idx < ARRAY_SIZE ; idx++)
{
res[idx] = a[idx] + b[idx];
}
end_time = clock();
printf("cpu Time : %f\n", ((double)(end_time-start_time)) / CLOCKS_PER_SEC);
cudaMalloc(&dev_a, ARRAY_SIZE * sizeof(int));
cudaMalloc(&dev_b, ARRAY_SIZE * sizeof(int));
cudaMalloc(&dev_c, ARRAY_SIZE * sizeof(int));
cudaMemcpy(dev_a, a, ARRAY_SIZE * sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dev_b, b, ARRAY_SIZE * sizeof(int), cudaMemcpyHostToDevice);
start_time = clock();
kernel_test<<<block,thread>>>(dev_a,dev_b,dev_c);
end_time = clock();
printf("gpu Time : %f\n", ((double)(end_time-start_time)) / CLOCKS_PER_SEC);
cudaMemcpy(c, dev_c, ARRAY_SIZE * sizeof(int), cudaMemcpyDeviceToHost);
for(idx = 0;idx < ARRAY_SIZE ; idx++)
{
if(res[idx] != c[idx])
{
printf("%5d a:%5d b:%5d c:%5d", idx, a[idx], b[idx], c[idx]);
if(res[idx] != c[idx])
printf(" != ");
else printf(" == ");
printf("r:%5d\n",res[idx]);
break;
}
}
cudaFree(dev_a);
cudaFree(dev_b);
cudaFree(dev_c);
free(a);
free(b);
free(c);
free(res);
}
| cuda + openmp 적용 예제 (0) | 2014.01.17 |
|---|---|
| cuda + openmp 프로젝트 생성은.... (0) | 2014.01.17 |
| CUDA 쓰레드 계산 (0) | 2014.01.15 |
| visual studio 2008 nsight 실행..된거 맞나? (0) | 2014.01.15 |
| nsight 설치... -_- (0) | 2014.01.15 |
| threadIdx.x +blockIdx.x * blockDim.x + (gridDim.x * blockDim.x) * (blockIdx.y * blockDim.y + threadIdx.y); |
| cuda + openmp 프로젝트 생성은.... (0) | 2014.01.17 |
|---|---|
| cuda 1차원 데이터, 2차원 처리 예제 (4) | 2014.01.16 |
| visual studio 2008 nsight 실행..된거 맞나? (0) | 2014.01.15 |
| nsight 설치... -_- (0) | 2014.01.15 |
| cuda 1 block 1차원 & 2차원 thread 예제 (0) | 2014.01.14 |
Installed에 똭! 추가!
기본 값은 Launcher debugging enabled False이므로
True로 바꾸어 주고(위에것도 해야하려나?)
VS2008의 디버거를 사용하지 말고 그냥
Start CUDA Debugging을 누르면 지가 알아서 실행되고 프로파일링 한다.
머하다가 이게 떴더라..?
막 누르다 보니.. 정신없는데..
Application Control에 Launch를 누르면 프로그램이 실행되면서
Nsight에서 녹화하고 그 데이터를 기반으로 디버깅 정보를 출력한다.
Summary Report 아직 보는 법은 모르겠고
nsight를 설치해서인지 VS2008 자체 디버거로 실행시 kernel에서 내장 변수들이 출력된다.
근데.. 막 건너뛰는 기분..(마스터 쓰레드만 하나 출력되려나?)
| cuda 1차원 데이터, 2차원 처리 예제 (4) | 2014.01.16 |
|---|---|
| CUDA 쓰레드 계산 (0) | 2014.01.15 |
| nsight 설치... -_- (0) | 2014.01.15 |
| cuda 1 block 1차원 & 2차원 thread 예제 (0) | 2014.01.14 |
| cuda 5.5 조금은 더 빠르게 컴파일 하기 (0) | 2014.01.14 |
| CUDA 쓰레드 계산 (0) | 2014.01.15 |
|---|---|
| visual studio 2008 nsight 실행..된거 맞나? (0) | 2014.01.15 |
| cuda 1 block 1차원 & 2차원 thread 예제 (0) | 2014.01.14 |
| cuda 5.5 조금은 더 빠르게 컴파일 하기 (0) | 2014.01.14 |
| GTX650 / ion devicequery (4) | 2014.01.13 |
| 0 a:26326 b:14567 c:40893 == r:40893
1 a:20769 b:29469 c:50238 == r:50238
2 a:19293 b:19828 c:39121 == r:39121
3 a: 5720 b:16164 c:21884 == r:21884
4 a:10116 b:16010 c:26126 == r:26126
5 a:24503 b: 1380 c:25883 == r:25883
6 a: 1261 b:20500 c:21761 == r:21761
7 a:32527 b:14265 c:46792 == r:46792
8 a: 6165 b: 1639 c: 7804 == r: 7804
9 a:16881 b: 7619 c:24500 == r:24500
10 a:14636 b: 3016 c:17652 == r:17652
11 a:20766 b: 1675 c:22441 == r:22441
12 a:24356 b: 3886 c:28242 == r:28242
13 a: 9279 b:15721 c:25000 == r:25000
14 a:20744 b: 74 c:20818 == r:20818
15 a:24023 b:17957 c:41980 == r:41980
16 a: 399 b:19653 c:20052 == r:20052
17 a: 9077 b: 9308 c:18385 == r:18385
18 a:18673 b: 713 c:19386 == r:19386
19 a:17966 b:12837 c:30803 == r:30803
20 a:28921 b:31938 c:60859 == r:60859
21 a:20298 b:18933 c:39231 == r:39231
22 a:18267 b:31334 c:49601 == r:49601
23 a:17726 b:18368 c:36094 == r:36094
24 a:10825 b:19187 c:30012 == r:30012
25 a:15579 b: 9569 c:25148 == r:25148
26 a:17217 b:27831 c:45048 == r:45048
27 a: 2756 b:13884 c:16640 == r:16640
28 a:25641 b:17878 c:43519 == r:43519
29 a:10533 b:17954 c:28487 == r:28487
30 a:15005 b:23112 c:38117 == r:38117
31 a: 9634 b: 8053 c:17687 == r:17687 |
#include < stdio.h >
#include < stdlib.h >
#include < time.h >
#include "cuda_runtime.h"
#define ARRAY_SIZE 32
__global__ void kernel_test(int *a, int *b, int *c)
{
int idx = threadIdx.x;
c[idx] = a[idx] + b[idx];
}
void main()
{
int a[ARRAY_SIZE],b[ARRAY_SIZE],c[ARRAY_SIZE],res[ARRAY_SIZE];
int *dev_a,*dev_b,*dev_c;
int idx = 0;
dim3 block(1);
dim3 thread(ARRAY_SIZE);
// initialize
srand (time(NULL));
for(idx = 0;idx < ARRAY_SIZE ; idx++)
{
a[idx] = rand();
b[idx] = rand();
res[idx] = a[idx] + b[idx];
c[idx] = 0;
}
cudaMalloc(&dev_a, ARRAY_SIZE * sizeof(int));
cudaMalloc(&dev_b, ARRAY_SIZE * sizeof(int));
cudaMalloc(&dev_c, ARRAY_SIZE * sizeof(int));
cudaMemcpy(dev_a, a, ARRAY_SIZE * sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dev_b, b, ARRAY_SIZE * sizeof(int), cudaMemcpyHostToDevice);
kernel_test<<<block,thread>>>(dev_a,dev_b,dev_c);
cudaMemcpy(c, dev_c, ARRAY_SIZE * sizeof(int), cudaMemcpyDeviceToHost);
for(idx = 0;idx < ARRAY_SIZE ; idx++)
{
printf("%5d a:%5d b:%5d c:%5d", idx, a[idx], b[idx], c[idx]);
if(res[idx] != c[idx])
printf(" != ");
else printf(" == ");
printf("r:%5d\n",res[idx]);
}
cudaFree(dev_a);
cudaFree(dev_b);
cudaFree(dev_c);
}
#define ARRAY_SIZE 64
__global__ void kernel_test(int *a, int *b, int *c)
{
int idx = threadIdx.x + threadIdx.y * 8;
c[idx] = a[idx] + b[idx];
}
void main()
{
dim3 block(1);
dim3 thread(8,8);
}
| visual studio 2008 nsight 실행..된거 맞나? (0) | 2014.01.15 |
|---|---|
| nsight 설치... -_- (0) | 2014.01.15 |
| cuda 5.5 조금은 더 빠르게 컴파일 하기 (0) | 2014.01.14 |
| GTX650 / ion devicequery (4) | 2014.01.13 |
| cuda dim3 변수 초기화 (0) | 2014.01.13 |
| nsight 설치... -_- (0) | 2014.01.15 |
|---|---|
| cuda 1 block 1차원 & 2차원 thread 예제 (0) | 2014.01.14 |
| GTX650 / ion devicequery (4) | 2014.01.13 |
| cuda dim3 변수 초기화 (0) | 2014.01.13 |
| vs2008 cuda syntax highlight (0) | 2014.01.13 |
전체 비교
| cuda 1 block 1차원 & 2차원 thread 예제 (0) | 2014.01.14 |
|---|---|
| cuda 5.5 조금은 더 빠르게 컴파일 하기 (0) | 2014.01.14 |
| cuda dim3 변수 초기화 (0) | 2014.01.13 |
| vs2008 cuda syntax highlight (0) | 2014.01.13 |
| VS2008 + cuda5.5 프로젝트 생성 (0) | 2014.01.13 |
| dim3 valname(x,y,z); dim3 valname(x,y); dim3 valname(x); |
| dim3 testdim3 = {1,1,1};
dim3 testdim2 = {1,1}
dim3 testdim1 = {1} |
| error: initialization with "{...}" is not allowed for object of type "dim3"
error: initialization with "{...}" is not allowed for object of type "dim3"
error: initialization with "{...}" is not allowed for object of type "dim3" |
struct __device_builtin__ dim3
{
unsigned int x, y, z;
#if defined(__cplusplus)
__host__ __device__ dim3(unsigned int vx = 1, unsigned int vy = 1, unsigned int vz = 1) : x(vx), y(vy), z(vz) {}
__host__ __device__ dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {}
__host__ __device__ operator uint3(void) { uint3 t; t.x = x; t.y = y; t.z = z; return t; }
#endif /* __cplusplus */
};
typedef __device_builtin__ struct dim3 dim3;
| cuda 5.5 조금은 더 빠르게 컴파일 하기 (0) | 2014.01.14 |
|---|---|
| GTX650 / ion devicequery (4) | 2014.01.13 |
| vs2008 cuda syntax highlight (0) | 2014.01.13 |
| VS2008 + cuda5.5 프로젝트 생성 (0) | 2014.01.13 |
| nvidia ion + ubuntu 12.04 LTS + cuda5.5 (0) | 2014.01.08 |