Tuesday, February 28, 2012

openMP enabling in Makefile

쿨럭 이걸 빼먹다니..
openMP를 Enabling 하기 위해선..
옵션에
CFLAGS = -fopenmp 가 필요 하다 뭐?? 이리 간단해?
그럼 안드로이드에선
LOCAL_CFLAGS += -fopenmp를 하면 되것군... 이제 빌드중... 형 제발 ㅠㅠ

한가지 더, 옵션 스페시픽을 위해서
CFLAGS = -std=gnu9x 를 넣어 주는데
안드로이드에선 아마... 아마.. 않넣어도 될듯 이미.. GCC 4.4.x 를 사용하니깐..
제발..

Monday, February 27, 2012

OpenGL|ES 2.0

Android includes support for high performance 2D and 3D graphics with the Open Graphics Library (OpenGL), specifically, the OpenGL ES API. OpenGL is a cross-platform graphics API that specifies a standard software interface for 3D graphics processing hardware. OpenGL ES is a flavor of the OpenGL specification intended for embedded devices. The OpenGL ES 1.0 and 1.1 API specifications have been supported since Android 1.0. Beginning with Android 2.2 (API Level 8), the framework supports the OpenGL ES 2.0 API specification.


OpenGL 은 그림을 그리는 툴, 그리는 솜씨라고 생각 하면된다.
EGL 이 준비 해놓은 캔버스에 그림을 그리는것이다. EGL 은 캔버스(메모리) 그리고 OpenGL|ES 2.0 이 사용할수 있는것들을 마련해 둔다, 그리고 디폴트 디스플래이 (LCD)를 확인한다.
그러면 OpenGL 을 통해서 그림을 그리는것이다.
응응..

OpenMP example;)





Original Sequential version of MXV in C

 42 #include <stdio.h>
 43 #include <stdlib.h>
 44
 45 void mxv(int m, int n, double * restrict a,
 46          double * restrict b, double * restrict c);
 47
 48 int main(int argc, char *argv[])
 49 {
 50    double *a,*b,*c;
 51    int i, j, m, n;
 52
 53    //printf("Please give m and n: ");
 54    //scanf("%d %d",&m,&n);
 55    printf("runnging 10000 * 10000 matrics x vector\n");
 56    m = 10000;
 57    n = 10000;
 58
 59    if ( (a=(double *)malloc(m*sizeof(double))) == NULL )
 60       perror("memory allocation for a");
 61    if ( (b=(double *)malloc(m*n*sizeof(double))) == NULL )
 62       perror("memory allocation for b");
 63    if ( (c=(double *)malloc(n*sizeof(double))) == NULL )
 64       perror("memory allocation for c");
 65
 66    printf("Initializing matrix B and vector c\n");
 67    for (j=0; j<n; j++)
 68       c[j] = 2.0;
 69    for (i=0; i<m; i++)
 70       for (j=0; j<n; j++)
 71          b[i*n+j] = i;
 72
 73    printf("Executing mxv function for m = %d n = %d\n",m,n);
 74    (void) mxv(m, n, a, b, c);
 75
 76    free(a);free(b);free(c);
 77    return(0);
 78 }
 79
 80 void mxv(int m, int n, double * restrict a, double * restrict b,
 81          double * restrict c)
 82 {
 83    int i, j;
 84
 85    for (i=0; i<m; i++)
 86    {
 87       a[i] = 0.0;
 88       for (j=0; j<n; j++)
 89          a[i] += b[i*n+j]*c[j];
 90    }

and OpenMP 
 42 #include <stdio.h>
 43 #include <stdlib.h>
 44
 45 void mxv(int m, int n, double * restrict a,
 46          double * restrict b, double * restrict c);
 47
 48 int main(int argc, char *argv[])
 49 {
 50    double *a,*b,*c;
 51    int i, j, m, n;
 52
 53    //printf("Please give m and n: ");
 54    //scanf("%d %d",&m,&n);
 55    printf("running 10000 * 10000 matrics x vectors\n");
 56    m = 10000;
 57    n = 10000;
 58
 59    if ( (a=(double *)malloc(m*sizeof(double))) == NULL )
 60       perror("memory allocation for a");
 61    if ( (b=(double *)malloc(m*n*sizeof(double))) == NULL )
 62       perror("memory allocation for b");
 63    if ( (c=(double *)malloc(n*sizeof(double))) == NULL )
 64       perror("memory allocation for c");
 65
 66    printf("Initializing matrix B and vector c\n");
 67    for (j=0; j<n; j++)
 68       c[j] = 2.0;
 69    for (i=0; i<m; i++)
 70       for (j=0; j<n; j++)
 71          b[i*n+j] = i;
 72
 73    printf("Executing mxv function for m = %d n = %d\n",m,n);
 74    (void) mxv(m, n, a, b, c);
 75
 76    free(a);free(b);free(c);
 77    return(0);
 78 }
 79
 80 void mxv(int m, int n, double * restrict a, double * restrict b,
 81          double * restrict c)
 82 {
 83    int i, j;
 84 #pragma omp parallel for default(none) \
 85         shared(m,n,a,b,c) private(i,j)
 86    for (i=0; i<m; i++)
 87    {
 88       a[i] = 0.0;
 89       for (j=0; j<n; j++)
 90          a[i] += b[i*n+j]*c[j];
 91    } /*-- End of omp parallel for --*/
 92 }

OpenMP will check your processors and will create # of threads.
in my case it creates 16 threads for doing mxv functions.

you can check # of threads with omp_get_number_threads();
and also set # of threads with omp_set_number_threads(#number);
or #pragma omp num_threads(#number)

results for those two sample codes are
 time ./fig3.5.exe
runnging 10000 * 10000 matrics x vector
Initializing matrix B and vector c
Executing mxv function for m = 10000 n = 10000

real    0m1.197s
user    0m0.688s
sys     0m0.508s

 time ./fig3.10.exe
running 10000 * 10000 matrics x vectors
Initializing matrix B and vector c
Executing mxv function for m = 10000 n = 10000

real    0m0.831s
user    0m3.700s
sys     0m0.456s






Friday, February 24, 2012

/system/bin/sh: girl : not found
/system/bin/sh: GF: not found
/system/bin/sh: woman: not found


not found.

My Computer:)

Intel i7 2600k
Nvidia GTX 570
650W PSU Corsair
1TB HDD + 60GB SSD
8GB DDR3 1600
It runs MW3 MAX, SC2 MAX, TERA MAX setting;)
I am gonna buy H80 - H100 coolmaster's liquid cooler for overclocking
and may change PSU someday ;)

SO waiting for Diablo 3 now

Thursday, February 23, 2012

Echoed

http://echoedmusic.com/

ㅋㅋㅋㅋ

#pragma

OpenMP를 쓰려면 #pragma를 사용 해야 하는것을 볼수 있다
역시 SurfaceFlinger.cpp 에서 threadLoop를 보면 바로 펑션 위에
#if 0
#pragma mark -
#pragma mark Main Loop
#endif 라는 구문을 볼수 있다.

그럼
#pragma는 뭘까?

The `#pragma' directive is the method specified by the C standard for providing additional information to the compiler, beyond what is conveyed in the language itself. Three forms of this directive (commonly known as pragmas) are specified by the 1999 C standard. A C compiler is free to attach any meaning it likes to other pragmas.

요놈은 결국 컴파일링 할때 몇몇가지 정보를 주는것이다.
#pragma omap for << 여기서 부터 OpenMP for loop 이 있다! 고로 여기서 부터 뜨래드를 실행하라
뭐 이런식으로 컴파일러에게 정보를 주는것이다.

Wednesday, February 22, 2012

내 .vimrc 설정


  1 set nocompatible
  2
  3 set nu
  4
  5 filetype on
  6
  7 set history=1000
  8
  9 syntax on
 10
 11 set autoindent
 12
 13 set smartindent
 14
 15 set hlsearch
 16
 17 set tabstop=4
 18
 19 set shiftwidth=4
 20
 21 set showmatch
 22
 23 set guioptions-=T
 24
 25 set ruler
 26
 27 set incsearch

내 .bashrc 설정 ;)



 1 # ~/.bashrc: executed by bash(1) for non-login shells.
  2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3 # for examples
  4 PS1='\[\e[1;32m\][\u\[\e[1;33m\] \w\[\e[1;32m\]] \[\e[0m\]'
  5
  6 # If not running interactively, don't do anything
  7 [ -z "$PS1" ] && return
  8
  9 # don't put duplicate lines in the history. See bash(1) for more options
 10 # ... or force ignoredups and ignorespace
 11 HISTCONTROL=ignoredups:ignorespace
 12
 13 # append to the history file, don't overwrite it
 14 shopt -s histappend
 15
 16 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
 17 HISTSIZE=1000
 18 HISTFILESIZE=2000
 19
 20 # check the window size after each command and, if necessary,
 21 # update the values of LINES and COLUMNS.
 22 shopt -s checkwinsize
 23
 24 # make less more friendly for non-text input files, see lesspipe(1)
 25 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
 26
 27 # set variable identifying the chroot you work in (used in the prompt below)
 28 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
 29     debian_chroot=$(cat /etc/debian_chroot)
 30 fi
 31
 32 # set a fancy prompt (non-color, unless we know we "want" color)
 33 case "$TERM" in
 34     xterm-color) color_prompt=yes;;
 35 esac
 36
 37 # uncomment for a colored prompt, if the terminal has the capability; turned
 38 # off by default to not distract the user: the focus in a terminal window
 39 # should be on the output of commands, not on the prompt
 40 #force_color_prompt=yes
 41
 42 if [ -n "$force_color_prompt" ]; then
 43     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
 44     # We have color support; assume it's compliant with Ecma-48
 45     # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
 46     # a case would tend to support setf rather than setaf.)
 47     color_prompt=yes
 48     else
 49     color_prompt=
50     fi
 51 fi
 52
 53 unset color_prompt force_color_prompt
 54
 55 # enable color support of ls and also add handy aliases
 56 if [ -x /usr/bin/dircolors ]; then
 57     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
 58     alias ls='ls --color=auto'
 59     #alias dir='dir --color=auto'
 60     #alias vdir='vdir --color=auto'
 61
 62     alias grep='grep --color=auto'
 63     alias fgrep='fgrep --color=auto'
 64     alias egrep='egrep --color=auto'
 65 fi
 66
 67 # some more ls aliases
 68 alias ll='ls -alF'
 69 alias la='ls -A'
 70 alias l='ls -al'
 71 alias u='cd ..'
 72 alias r='cd ~'
 73 alias p='cd -'
 74 alias mygrep='grep -RHni --exclude=.git --exclude=svn'
 75
 76 # Alias definitions.
 77 # You may want to put all your additions into a separate file like
 78 # ~/.bash_aliases, instead of adding them here directly.
 79 # See /usr/share/doc/bash-doc/examples in the bash-doc package.
 80
 81 if [ -f ~/.bash_aliases ]; then
 82     . ~/.bash_aliases
 83 fi
 84
 85 # enable programmable completion features (you don't need to enable
 86 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
 87 # sources /etc/bash.bashrc).
 88 if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
 89     . /etc/bash_completion
 90 fi


ION


ION

goals
* Share buffers between hardware resource : Camera, Video encoder/decoder, GPU, and Display
* Ability to securely and safely share buffers with userspac
handle process temination
allow secure sharing between processes
* Modular and extensible to map to future hardware designs
요놈은 ICS에서 새로 들어온 메모리 얼로 케이션 메니져 라고 생각 하면 된다.
프로세서들이 많아 지고 그것들이 모두 사용 할수 있는 shared memory가 필요 해서
만든것. Secure sharing between processes 를 지원한다!!

Tuesday, February 21, 2012

Amdahl's law

OpenMP를 읽다가 Amdahl's law 가 나와서 위키를 뒤져 봤는데
아무리 프로 세서가 많아 지더라고 해도 퍼포먼스는 일정양에서 정지 된다.
어라 왜? 란 생각을 했었는데,
95% 의 프로그램이 같이 돌수 있다 하더라도 무지 막지한 프로 세서를 가졌다 하더라도
스피드 업은 20배에서 멈춘다 음..
고래?
이유는 간단하다 5%의 프로그램은 프로 세서를 같이 사용할수 없다.
그말은 5%는 싱글 코어로 돌려야 한다는것.
그래서 내 서버 컴퓨터의 풀빌드걸리는 시간이 30분 정도에서 멈춰 있는건가 ㅡㅡ;
안드로이드는 얼마나 parallel portion 을 가지고 있는지 궁금 하군.
http://en.wikipedia.org/wiki/Amdahl's_law

Saturday, February 18, 2012

MW3

모던 워 페어 3 ㅡㅡ;; 정말 최고의 게임이다..
그다지 중독성은 없지만 그 화질.. 그 음향...
내가 정말 전쟁 속으로 들어간듯한 느낌이랄까 ㅡㅡ;;
살만한 가치가 있는 게임... ㅇㅇ

Friday, February 17, 2012

OpenMP API

supports multi-platform shared-memory parallel programming in C/C++ and Fortran. The OpenMP API defines a portable, scalable model with a simple and flexible interface for developing parallel applications on platforms from the desktop to the supercomputer. 
이번 연도 너로 정했다!!!