쿨럭 이걸 빼먹다니..
openMP를 Enabling 하기 위해선..
옵션에
CFLAGS = -fopenmp 가 필요 하다 뭐?? 이리 간단해?
그럼 안드로이드에선
LOCAL_CFLAGS += -fopenmp를 하면 되것군... 이제 빌드중... 형 제발 ㅠㅠ
한가지 더, 옵션 스페시픽을 위해서
CFLAGS = -std=gnu9x 를 넣어 주는데
안드로이드에선 아마... 아마.. 않넣어도 될듯 이미.. GCC 4.4.x 를 사용하니깐..
제발..
안드로이드, OpenMP, OpenCL, Graphic, 컴퓨터 게임, Software Engineer, Ski, San Jose, 그리고 내가 사랑 하는 모든것들 ;) Feel free to add me, and ask me;)
Tuesday, February 28, 2012
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 을 통해서 그림을 그리는것이다.
응응..
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
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
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
Subscribe to:
Posts (Atom)