Programming/openCL & CUDA2014. 1. 13. 17:58
dim3는 uint3 형(unsigned int)으로 x,y,z 3개의 변수를 지니는 구조체다.
c++ 스타일과 c 스타일로 초기화가 각각 가능하며

C++ 스타일로는
dim3 valname(x,y,z);
dim3 valname(x,y);
dim3 valname(x); 
식으로 값이 없는 건 1로 선언되며

C 스타일로는
dim3 valname = {x,y,z};
으로 선언된다.

---
엥? c 스타일로는 선언 안되는데?
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" 
---

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\vector_types.h
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;

[링크 : http://choorucode.com/2011/02/16/cuda-dim3/]
Posted by 구차니
Programming/openCL & CUDA2014. 1. 13. 10:49
vs2005가 VS8 인데 이녀석으로 vs2008/VS9에 덮어 씌우며 된다.
usertype.dat 파일은 아래의 경로에 있는데 UUID가 들어가서 사용자 마다 다르게 추가될 가능성이 있다.

usertype.dat 파일을
C:\Program Files\NVIDIA Corporation\Installer2\CUDASamples_5.5.{5B964E0E-AB97-450D-9C30-C390798C19EB}\doc\syntax_highlighting\visual_studio_8\usertype.dat

아래의 경로에 복사한다.
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\usertype.dat

readme.txt
Want pretty syntax highlighting when editing your .cu files in Visual Studio?
Here's how:

---
Visual Studio .Net 2005 / Visual Studio 8:

1. If you don't have a usertype.dat file in your "Microsoft Visual Studio 8\Common7\IDE" folder, then copy the included usertype.dat file there.  If you do, append the contents of the included usertype.dat onto the end of the "Microsoft Visual Studio 8\Common7\IDE\usertype.dat"

2. Start Visual Studio 8.  Select the menu "Tools->Options...".  Open "Text Editor" in the tree view on the left, and click on "File Extension".  Type cu in the "Extension" box, set the editor to "Microsoft Visual C++" and click "Add".  Click "OK" on the dialog box.  

3. Restart Visual Studio and your CUDA code should now have syntax highlighting. 

그리고는 Visual Studio의 도구 - 옵션 - 텍스트 에디터에서


파일 확장명에 cu를 축가하고 편집기를 "Microsoft Visual C++"으로 선택후 적용하면 된다.


dim3 타입까지 색상이 들어가는 것을 확인!


[링크 : http://stackoverflow.com/questions/5077104/how-can-i-get-syntax-highlighting-for-a-cu-file-in-visual-studio]

'Programming > openCL & CUDA' 카테고리의 다른 글

GTX650 / ion devicequery  (4) 2014.01.13
cuda dim3 변수 초기화  (0) 2014.01.13
VS2008 + cuda5.5 프로젝트 생성  (0) 2014.01.13
nvidia ion + ubuntu 12.04 LTS + cuda5.5  (0) 2014.01.08
cuda on windows 7  (0) 2014.01.06
Posted by 구차니
Programming/openCL & CUDA2014. 1. 13. 10:23
예전에는 복잡하게 룰을 추가해야 했는데
2011/01/04 - [Programming/openCL / CUDA] - Visual Studio 2008 에서 CUDA 프로젝트 만들기

기본 템플렛이 추가 되어 있어서 편리하게 만들수 있다.


그런데.. 기본적으로 5개 짜리 더하는 예제가 추가되는건가?
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include < stdio.h >

cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);

__global__ void addKernel(int *c, const int *a, const int *b)
{
    int i = threadIdx.x;
    c[i] = a[i] + b[i];
}

int main()
{
    const int arraySize = 5;
    const int a[arraySize] = { 1, 2, 3, 4, 5 };
    const int b[arraySize] = { 10, 20, 30, 40, 50 };
    int c[arraySize] = { 0 };

    // Add vectors in parallel.
    cudaError_t cudaStatus = addWithCuda(c, a, b, arraySize);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "addWithCuda failed!");
        return 1;
    }

    printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n",
        c[0], c[1], c[2], c[3], c[4]);

    // cudaDeviceReset must be called before exiting in order for profiling and
    // tracing tools such as Nsight and Visual Profiler to show complete traces.
    cudaStatus = cudaDeviceReset();
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaDeviceReset failed!");
        return 1;
    }

    return 0;
}

// Helper function for using CUDA to add vectors in parallel.
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size)
{
    int *dev_a = 0;
    int *dev_b = 0;
    int *dev_c = 0;
    cudaError_t cudaStatus;

    // Choose which GPU to run on, change this on a multi-GPU system.
    cudaStatus = cudaSetDevice(0);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?");
        goto Error;
    }

    // Allocate GPU buffers for three vectors (two input, one output)    .
    cudaStatus = cudaMalloc((void**)&dev_c, size * sizeof(int));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMalloc failed!");
        goto Error;
    }

    cudaStatus = cudaMalloc((void**)&dev_a, size * sizeof(int));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMalloc failed!");
        goto Error;
    }

    cudaStatus = cudaMalloc((void**)&dev_b, size * sizeof(int));
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMalloc failed!");
        goto Error;
    }

    // Copy input vectors from host memory to GPU buffers.
    cudaStatus = cudaMemcpy(dev_a, a, size * sizeof(int), cudaMemcpyHostToDevice);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMemcpy failed!");
        goto Error;
    }

    cudaStatus = cudaMemcpy(dev_b, b, size * sizeof(int), cudaMemcpyHostToDevice);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMemcpy failed!");
        goto Error;
    }

    // Launch a kernel on the GPU with one thread for each element.
    addKernel<<<1, size>>>(dev_c, dev_a, dev_b);

    // Check for any errors launching the kernel
    cudaStatus = cudaGetLastError();
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus));
        goto Error;
    }
    
    // cudaDeviceSynchronize waits for the kernel to finish, and returns
    // any errors encountered during the launch.
    cudaStatus = cudaDeviceSynchronize();
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
        goto Error;
    }

    // Copy output vector from GPU buffer to host memory.
    cudaStatus = cudaMemcpy(c, dev_c, size * sizeof(int), cudaMemcpyDeviceToHost);
    if (cudaStatus != cudaSuccess) {
        fprintf(stderr, "cudaMemcpy failed!");
        goto Error;
    }

Error:
    cudaFree(dev_c);
    cudaFree(dev_a);
    cudaFree(dev_b);
    
    return cudaStatus;
}

'Programming > openCL & CUDA' 카테고리의 다른 글

cuda dim3 변수 초기화  (0) 2014.01.13
vs2008 cuda syntax highlight  (0) 2014.01.13
nvidia ion + ubuntu 12.04 LTS + cuda5.5  (0) 2014.01.08
cuda on windows 7  (0) 2014.01.06
cuda / cpu 테스트 드라이브  (0) 2014.01.06
Posted by 구차니
Programming/processing2014. 1. 12. 22:23
오랫만에 다시 들을 기회가 있어서
프로세싱을 받아서 실행해보니.. 과거의 칙칙한 연두색에서 벗어나
산뜻한 디자인으로 변경되었다.
2011/12/29 - [embeded/ATmega/ATtiny (AVR)] - 아두이노 (arduino)



getting start에서 복사한 코드로 대충 실행
setup() 과 draw() 두개의 함수가 존재할 뿐인데 이렇게 창이 생기고 그림이 그려지다니!!


웬지 마음에 드는 'copy as HTML' 


상단의 Java를 눌러 Add Mode를 하면 이런게 뜨는데..
java가 아닌 다른걸 통해서도 실행을 하게 하는 걸려나?


+
심심해서 Mode Manager에서 JavaScript Mode를 추가하고 재실행


Java 대신 JavaScript 로 변경후 Run!


웹 브라우저가 뜨면서 Java 애플릿을 통해 실행되는 것.. .같다?
(일단 브라우저 경고를 띄우니...) 





초기 버전에는 jre가 포함이었는지 설치가 되어서 그냥 썼는지
독립적으로 그린건지 기억이 안나서.. 비교가 불가
아무튼.. 우분투에서도 java를 설치하는 것 봐서는 기본적으로 java를 이용해 그리는것 같다.
[링크 : http://www.spacemig.com/2012/07/installing-processing-in-ubuntu-12-04/]

[링크 : http://processing.org/download/?processing] 다운로드 
[링크 : http://processing.org/tutorials/gettingstarted/] getting start

'Programming > processing' 카테고리의 다른 글

프로세싱(언어)  (0) 2013.01.08
processing (언어)  (0) 2012.05.04
Posted by 구차니
집에서 성화를 해서 갔다 와봤는데
[링크 : http://www.kscv.org/] 행사 홈페이지

그닥.. 볼게 없다는 느낌?
입구에 3d 프린터 외에는 참관 업체들이 눈에 띄는게 없었고
[링크 : http://rokit.co.kr/] 3d 프린터
[링크 : http://www.fablab-seoul.org/] 3d 스캐너

그외에 즉석 구인/구직 부스는 업체 이름만 잔뜩 써있어서 
사전 조사 없이는 면접보기도 참.. 애매한 상황. 게다가 언어 장벽 끄아아 ㅠㅠ

아무튼, 돌아 다니면서 몇군데 눈에 들어온 곳 목록

TNV / safevisions 업체 홈페이지(안전운전 도우미)
[링크 : http://www.safevisions.com/]

하이펀 / mySen-MoCa (자이로+가속도 센서 기반 모션캡쳐 솔루션)
[링크 : http://hyfun.co.kr/]
Posted by 구차니
일단 계좌제가 아직 안된 관계로
자비로 하는데

다행히도 48만원 정도 하는거 20% 할인해서 38만 4천원에 수강
책값도 2.5만원 정도 지원해준다고 하니 웬지 이득보는 느낌?

근데.. 내가 필요로 하는 기능/능력을 이걸 통해서 배울수 있는지가 미지수니까..
그것도 또 그것 나름대로 불안하네.. 
Posted by 구차니
개소리 왈왈/자전거2014. 1. 11. 20:08
아 춰춰춰
아.. 먼가 잊은게 있었나 했떠니..
돌아올때 안찍었구나.. ㅠㅠ


'개소리 왈왈 > 자전거' 카테고리의 다른 글

3.1절 맞이 시즌 온 자전거 타기  (0) 2014.03.01
오늘의 지름 - 휴대용 토크렌찌  (0) 2014.02.28
2014 랜도너스 도전?  (2) 2013.12.23
바이크 쇼 2013  (6) 2013.11.29
금강 종주 완료  (0) 2013.11.23
Posted by 구차니
할인되서 저렇게 싼줄 알고
맥북 프로를 지르려고 했더니 ㅋㅋㅋㅋㅋ
할인금액이 6만원 13만원(맥북프로) ㅋㅋㅋㅋ
아오 ㅋㅋㅋㅋㅋ


Posted by 구차니
Programming/openCL & CUDA2014. 1. 8. 22:04
xrog.conf 설정 문제로 작동도 안되고 쑈하다가
modprobe 하고 나서의 여파인지 xorg.conf를 예전걸로 되돌린 여파인지 모르겠지만
어찌어찌 X window 실행이 가능해져서
부랴부랴 nbody와 만만한 fluidgl 두개를 돌려 보았다.

atom 330(1.6Ghz)에서는 절대 불가능 할거 같은 38프레임의 nbody ㄷㄷㄷ
아무튼.. ion이 2개의 MP 밖에 없음에도 불구하고 꽤나 좋은 성능을 내주는 것 같다.


이녀석은.. 희한하게 프레임이 안나오네



'Programming > openCL & CUDA' 카테고리의 다른 글

vs2008 cuda syntax highlight  (0) 2014.01.13
VS2008 + cuda5.5 프로젝트 생성  (0) 2014.01.13
cuda on windows 7  (0) 2014.01.06
cuda / cpu 테스트 드라이브  (0) 2014.01.06
cuda on ubuntu 12.04 LTS  (0) 2014.01.06
Posted by 구차니
ZDnet 기사인데
전제가 잘못되었다.. 랄까?

[링크 : http://media.daum.net/digital/others/newsview?newsid=20140107174106243]




일단 한국에서 리눅스가 대중화 되지 못하는 이유는
1. ActiveX로 인한 탈 IE 불가능(공인인증서, 키보드 보안 등등)
2. MS Office 외에는 호환이 불가능한 과도한 서식(libre office 등으로 대체가 불가능할 정도)
3. 익숙함을 벗어나지 않으려는 안일함


솔찍히 나 역시 메인은 리눅스를 쓰지 않는 이유는
한국에서는 카드결제를 하려고 하거나 각종 거래를 하려고 하면
반드시 공인인증서와 ie에서 작동하는 플러그 인을 설치해야 하고


가장 중요한 게임(!)은 mac용으로도 나오지 않고 오로지 윈도우용으로만 나오며


회사에서는 ms 제품이 아니면 사용이 불가능할 정도로 친 ms 환경이다.  
아웃룩을 쓰더라도 아웃룩이 아닌 사람들에게 배려가 되어야 하는데
그렇게 설정이 되어있지 않아 반드시 아웃룩을 써야만 하고
엑셀이나 워드 등도 공개표준이 아닌데(doc시절. docx등의 xml 포맷은 공개 되어 있다지만..
업무적으로 문서주고 받을때 구버전 호환을 위해 docx로는 주고 받지 않음) 그걸로 주고 받고
미친듯한 서식으로 ms 에서도 버전이 다르면 깨질정도로 쓸데없이 꾸미는 문제가 있다.


머.. 솔찍히 리눅스가 쓰기 아주 편한건 아니지만
(우스개 소리로 윈도우의 최고 기술은 껐다켜면 정상작동하는거라고 주장하지만)
그렇다고 해서 리눅스가 아주 못쓸건 아님에도 불구하고
단지 익숙하지 않은 프로그램을 찾아서 버벅이는 과정을 겪기 싫다는
윗사람의 주장으로 인해 꾸준히 이러한 MS 독점 현상이 유지 되고 있다는것 자체가
문제 아닐까?
Posted by 구차니