'Programming'에 해당되는 글 1721건

  1. 2014.01.13 vs2008 cuda syntax highlight
  2. 2014.01.13 VS2008 + cuda5.5 프로젝트 생성
  3. 2014.01.12 processing 실행
  4. 2014.01.08 nvidia ion + ubuntu 12.04 LTS + cuda5.5
  5. 2014.01.06 cuda on windows 7
  6. 2014.01.06 cuda / cpu 테스트 드라이브
  7. 2014.01.06 cuda on ubuntu 12.04 LTS
  8. 2014.01.06 cuda 5.5
  9. 2013.12.18 assert()
  10. 2013.12.12 openGL state variables
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 구차니
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 구차니
Programming/openCL & CUDA2014. 1. 6. 15:21
드라이버와 문서 / 예제코드 / 툴킷이 포함되어 있다.


기본 설치 위치는 아래와 같이 각양각색이다.


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

VS2008 + cuda5.5 프로젝트 생성  (0) 2014.01.13
nvidia ion + ubuntu 12.04 LTS + cuda5.5  (0) 2014.01.08
cuda / cpu 테스트 드라이브  (0) 2014.01.06
cuda on ubuntu 12.04 LTS  (0) 2014.01.06
cuda 5.5  (0) 2014.01.06
Posted by 구차니
Programming/openCL & CUDA2014. 1. 6. 15:20
Telsa K20 GPU 원격 클로스터 로그인 데모 가입인거 같은데
들어 본적 없는 어플리케이션들 뿐이라, 돌려볼 방법도 몰라서 무의미해져 버린 좋은기회 ㅠㅠ


[링크 : http://www.nvidia.co.kr/object/gpu-test-drive-kr.html]

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

nvidia ion + ubuntu 12.04 LTS + cuda5.5  (0) 2014.01.08
cuda on windows 7  (0) 2014.01.06
cuda on ubuntu 12.04 LTS  (0) 2014.01.06
cuda 5.5  (0) 2014.01.06
CUDA Capability별 기능차이  (0) 2013.02.17
Posted by 구차니
Programming/openCL & CUDA2014. 1. 6. 10:52
deb 패키지로 지원을 해서 한번 깔아 보는데 엌ㅋㅋㅋ


run으로 설치시에는 /usr/local/cuda-5.5 에
Install the CUDA 5.5 Toolkit? ((y)es/(n)o/(q)uit): n
Install the CUDA 5.5 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/minimonk/NVIDIA_CUDA-5.5_Samples ]:
Enter Toolkit Location [ default is /usr/local/cuda-5.5 ]: 

deb 패키지 설치시에는 /usr/local/cuda에 설치된다. (32bit 기준)
[링크 : http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html]

일단.. 설치된건 cuda repo 이니.. 추가로  cuda-dev와 cuda-doc을 설치 해봐야징..
$ sudo apt-cache search cuda
boinc-nvidia-cuda - metapackage for CUDA-savvy BOINC client and manager
libthrust-dev - Thrust - C++ template library for CUDA
pyrit - GPGPU-driven WPA/WPA2-PSK key cracker
python-pytools - big bag of things supplementing Python standard library
suricata - Next Generation Intrusion Detection and Prevention Tool
libcublas4 - NVIDIA CUDA BLAS runtime library
libcudart4 - NVIDIA CUDA runtime library
libcufft4 - NVIDIA CUDA FFT runtime library
libcurand4 - NVIDIA CUDA Random Numbers Generation runtime library
libcusparse4 - NVIDIA CUDA Sparse Matrix runtime library
libnpp4 - NVIDIA Performance Primitives runtime library
nvidia-compute-profiler - NVIDIA Compute Visual Profiler
nvidia-cuda-dev - NVIDIA CUDA development files
nvidia-cuda-doc - NVIDIA CUDA and OpenCL documentation
nvidia-cuda-gdb - NVIDIA CUDA GDB
nvidia-cuda-toolkit - NVIDIA CUDA toolkit
nvidia-304 - NVIDIA binary Xorg driver, kernel module and VDPAU library
nvidia-304-updates - NVIDIA binary Xorg driver, kernel module and VDPAU library
nvidia-319 - NVIDIA binary Xorg driver, kernel module and VDPAU library
nvidia-319-updates - NVIDIA binary Xorg driver, kernel module and VDPAU library
python-pycuda - Python module to access Nvidia‘s CUDA parallel computation API
python-pycuda-doc - module to access Nvidia‘s CUDA parallel computation API (documentation)
python-pycuda-headers - headers for Python module to access Nvidia‘s CUDA parallel computation API
cuda-repo-ubuntu1204 - CUDA repo configuration files. 

$ sudo apt-get install nvidia-cuda-dev nvidia-cuda-doc
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
다음 패키지를 더 설치할 것입니다:
  cpp-4.4 g++-4.4 gcc-4.4 gcc-4.4-base libcublas4 libcudart4 libcufft4 libcurand4 libcusparse4
  libnpp4 libqtassistantclient4 libstdc++6-4.4-dev libthrust-dev libvdpau-dev
  nvidia-compute-profiler nvidia-cuda-gdb nvidia-cuda-toolkit nvidia-opencl-dev opencl-headers
제안하는 패키지:
  gcc-4.4-locales g++-4.4-multilib gcc-4.4-doc libstdc++6-4.4-dbg gcc-4.4-multilib
  libmudflap0-4.4-dev libgcc1-dbg libgomp1-dbg libmudflap0-dbg libcloog-ppl0 libppl-c2 libppl7
  libstdc++6-4.4-doc libvdpau-doc
다음 새 패키지를 설치할 것입니다:
  cpp-4.4 g++-4.4 gcc-4.4 gcc-4.4-base libcublas4 libcudart4 libcufft4 libcurand4 libcusparse4
  libnpp4 libqtassistantclient4 libstdc++6-4.4-dev libthrust-dev libvdpau-dev
  nvidia-compute-profiler nvidia-cuda-dev nvidia-cuda-doc nvidia-cuda-gdb nvidia-cuda-toolkit
  nvidia-opencl-dev opencl-headers
0개 업그레이드, 21개 새로 설치, 0개 제거 및 4개 업그레이드 안 함.
142 M바이트 아카이브를 받아야 합니다.
이 작업 후 467 M바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까 [Y/n]? 

샘플 파일을 위해서는 run 파일로 설치해야 할듯..
그리고 샘플은 ${HOME}에 저장된다.
$ sudo ./cuda_5.5.22_linux_32.run
NVIDIA CUDA General Terms
-------------------------

The Software may collect non-personally identifiable
information for the purposes of customizing information
delivered to you and improving future versions of the
Software. Such information, including IP address and system
configuration, will only be collected on an anonymous basis
and cannot be linked to any personally identifiable
information. Personally identifiable information such as your
username or hostname is not collected.

-------------------------------------------------------------
Do you accept the previously read EULA? (accept/decline/quit): accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86 319.37? ((y)es/(n)o/(q)uit): y
Install the CUDA 5.5 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-5.5 ]:
Install the CUDA 5.5 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/minimonk/NVIDIA_CUDA-5.5_Samples ]:
Installing the NVIDIA display driver...
Installing the CUDA Toolkit in /usr/local/cuda-5.5 ...
Installing the CUDA Samples in /home/minimonk/NVIDIA_CUDA-5.5_Samples ...
Copying samples to /home/minimonk/NVIDIA_CUDA-5.5_Samples/NVIDIA_CUDA-5.5_Samples now...
Finished copying samples.

===========
= Summary =
===========

Driver:   Installed
Toolkit:  Installed in /usr/local/cuda-5.5
Samples:  Installed in /home/minimonk/NVIDIA_CUDA-5.5_Samples

* Please make sure your PATH includes /usr/local/cuda-5.5/bin

* Please make sure your LD_LIBRARY_PATH
*   for 32-bit Linux distributions includes /usr/local/cuda-5.5/lib
*   for 64-bit Linux distributions includes /usr/local/cuda-5.5/lib64:/lib
* OR
*   for 32-bit Linux distributions add /usr/local/cuda-5.5/lib
*   for 64-bit Linux distributions add /usr/local/cuda-5.5/lib64 and /lib
* to /etc/ld.so.conf and run ldconfig as root

* To uninstall CUDA, remove the CUDA files in /usr/local/cuda-5.5
* Installation Complete

Please see CUDA_Getting_Started_Linux.pdf in /usr/local/cuda-5.5/doc/pdf for detailed information on setting up CUDA.

Logfile is /tmp/cuda_install_5918.log

왜!!! 우분투에서 샘플 코드 까진 관리를 안해주는거야 ㅠㅠ

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

cuda on windows 7  (0) 2014.01.06
cuda / cpu 테스트 드라이브  (0) 2014.01.06
cuda 5.5  (0) 2014.01.06
CUDA Capability별 기능차이  (0) 2013.02.17
Nvidia GTX 시리즈별 코드네임  (0) 2013.02.17
Posted by 구차니
Programming/openCL & CUDA2014. 1. 6. 10:41
ㄷㄷㄷ 벌써 버전이 이렇게!!
일단.. 리눅스는 12.04 LTS 32bit / 2GB 짜리라.. 메모리라도 늘려줘야 하나? ㅠㅠ

 

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

cuda / cpu 테스트 드라이브  (0) 2014.01.06
cuda on ubuntu 12.04 LTS  (0) 2014.01.06
CUDA Capability별 기능차이  (0) 2013.02.17
Nvidia GTX 시리즈별 코드네임  (0) 2013.02.17
cuda deviceQuery on GTX650  (0) 2013.02.17
Posted by 구차니
Programming/C Win32 MFC2013. 12. 18. 01:55
한번쯤은 써봐야지하는 것 중에 하나
가장 강력하고 원초적인 디버깅 중에 하나로 printf()가 있다면
꽤나 상큼하고 스마트한 방법이라는데

assert()에서 비교문이 false 일 경우 강제종료 + 덤프를 한다고 한다.
일단 C/C++ 다 지원하는 듯..

NDEBUG가 정의되면 assert() 가 수행되지도 컴파일 되지도 않는다고 한다.
 #define NDEBUG // disable assert() calls

#include <assert.h>
void assert(scalar expression);
[링크 : http://linux.die.net/man/3/assert

[링크 : http://forum.falinux.com/zbxe/index.php?document_srl=408376&mid=C_LIB]
[링크 : http://www.cplusplus.com/reference/cassert/assert/]


---
2013.12.19
//#include <assert.h>
로 주석처리 하고 assert()를 부르면 컴파일 부터 배짼다 -_-
$ gcc c.c
/tmp/ccpSwySM.o: In function `main':
c.c:(.text+0x11): undefined reference to `assert'
collect2: ld returned 1 exit status 

#include "stdio.h"
#include "assert.h"

int main()
{
        assert(0);

        return 0;
}

음.. 우분투 12.04 LTS desktop에서 코어 덤프를 안하도록 해놔서 그런가..
덤프 파일이 생성되진 않았다.
$ gcc c.c
/tmp/ccpSwySM.o: In function `main':
c.c:(.text+0x11): undefined reference to `assert'
collect2: ld returned 1 exit status 

'Programming > C Win32 MFC' 카테고리의 다른 글

typeof  (0) 2014.03.11
const / pointer  (0) 2014.02.25
printf의 %s와 %S  (0) 2013.06.15
win32api - joystick 예제  (0) 2013.06.15
Windows IME  (0) 2013.02.14
Posted by 구차니
Programming/openGL2013. 12. 12. 22:01
조만간.. 이거 덤프하는 프로그램을 짜봐야지..


[링크 : http://www.glprogramming.com/]
    [링크 : http://www.glprogramming.com/red/appendixb.html]
Posted by 구차니