[CUDA] NVCC -gencode

코딩/CUDA 2014. 10. 8. 10:14

nvcc 사용시 -gencode 옵션은 -arch 옵션과 -code 옵셥을 합친 것이다.

 

-arch 옵션: '-arch=compute_20'과 같이 사용

생성될 PTX 코드의 버전을 지정        -> 'compute_XX'는 virtual architecture를 의미함

PTX 코드는 GPU 드라이버에서 JIT (Just-In-Time) 컴파일을 통해 실행이 가능함

(SDK가 필요 없다는 장점이 있음)

-code 옵션: '-code=sm_20'과 같이 사용

생성될 binary 코드(SASS)의 버전을 지정     -> 'sm_XX'는 real architecture를 의미함

binary 코드는 별도의 JIT 컴파일 과정 없이 지정된 architecture에서 곧바로 실행이 가능

(컴파일 시간이 짧다는 이점이 있음) 

-gencode 옵션: '-gencode arch=compute_20,code=sm_20'과 같이 사용

 

그렇다면 다음과 같이 한번에 여러 -gencode 옵션을 줄 때의 이점이 무엇인가.....하면....

-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_21,code=sm_21

 

여러 버전의 PTX, binary 코드를 미리 생성해두어 상위 아키텍쳐에 대한 '호환성'을 높일 수 있다는 것임.

대신 옵션 수에 비례하여 실행 코드의 크기가 커진다는 단점도 있음.

 

(참고: http://stackoverflow.com/questions/17599189/what-is-the-purpose-of-using-multiple-arch-flags-in-nvidias-nvcc-compiler)

[Math] What is a manifold?

수학 2014. 8. 21. 09:44

<Manifold란?>

Wikipedia 정의에 따르면,

In mathematics, a manifold is a topological space that resembles Euclidean space near each point. More precisely, each point of an n-dimensional manifold has a neighbourhood that is homeomorphic to the Euclidean space of dimension n. ... 

(출처: http://en.wikipedia.org/wiki/Manifold)

...라고 한다.-0-

 

나같은 비수학전공자에게는 전혀 와닿지 않은 문장이라서 '한방에' 이해하기 쉬운 설명을 찾던 중

다음과 같은 글을 발견! 

shortest description i've heard that i thought helped was that a manifold surface is one in which every edge is adjacent to two faces. i believe that property is necessary and sufficient.

e.g. a triangle is not a manifold surface - each edge is adjacent to a single face. a cube is a manifold surface. if you take one face away from the cube, it is no longer manifold.

some properties that come out of this - no open boundaries (like the cube missing a face), the surface is "air-tight", it has a distinct inside and outside surface, etc.

non-manifold is any surface that doesn't meet the requirement for a manifold surface.

(출처: https://www.opengl.org/discussion_boards/showthread.php/164373-what-is-manifold-and-non-manifold-surface)

 

딱 와닿지 않은가?? :D

쉽게 그림으로 보면 아래와 같은 것들이 manifold라고 할 수 있겠다.

(출처: http://mathworld.wolfram.com)

 

 

<Manifold의 차원?>

Manifold의 차원이란 manifold 상의 local area에 대응하는 Euclidean space의 차원에 대응한다.

예를 들면, 2차원 원의 경우 1차원 manifold라고 할 수 있는데, 원을 여러 부분으로 잘게 자르면 각 부분은 1차원 직선에 대응하기 때문이다.

비슷하게 3차원 구의 경우는, 구를 잘게 자른 각 patch는 2차원 평면에 대응하므로 2차원 manifold라고 할 수 있다.

[Python] Matplotlib을 이용한 histogram 그리기

코딩/Python 2014. 8. 4. 11:07

[Matplotlib 설치]

1. Numpy 설치

- 설치된 Python 버전에 맞는 numpy 설치

2. Matplotlib 설치

- 구글링해서 1.3.1 버전을 받아서 설치했더니 'matplotlib requires dateutil'이라는 에러 발생

- 그냥 아래 링크 설명대로 github에서 다시 받아서 설치했더니 문제 없었음
(http://matplotlib.org/users/installing.html)

 

[Histogram 그리기]

1. 예제 코드

- TP_list와 FP_list에 들어있는 값들에 대한 histogram을 겹쳐서 그림

- 'alpha=0.5'를 통해 투명도 조절

import matplotlib.pyplot as plt
...
plt.hist(TP_list, bins=100, color='b', label='TP')
plt.hist(FP_list, bins=100, color='r', alpha=0.5, label='FP')
plt.title('Score Histogram')
plt.xlabel('Scores')
plt.ylabel('Frequency')
plt.legend()
plt.show()

 

2. 그 외

- 자세한 설명은 생략한다 아래 링크 참조

(http://bespokeblog.wordpress.com/2011/07/11/basic-data-plotting-with-matplotlib-part-3-histograms/)

 

'코딩 > Python' 카테고리의 다른 글

[Python] 파일 라인 수정  (0) 2014.04.28