OpenCL主要分成四個部份
Platform model -- device 和 host
Execution model -- kernel如何在device上執行
Memory model -- abstract memory hierarchy
Programming model -- 定義concurrency model如何map 到physical hardware
(1) Initialize platforms
clGetPlatformIDs(...,...,...);
(2)Initialize devices
clGetDeviceIDs(...,...,...,...,...);
(3) Create a context
clCreateContext(...,...,...,...,...,...,...);
(4) Create a command queue
clCreateCommandQueue(...);
(5) Create device buffers
clCreateBuffer(...);
(6) Write host data to device buffers
clEnqueueWriteBuffer(...);
(7) Create and compile the program
clCreateProgramWithSource(...);
clBuildProgram(...);
(8) Create the kernel
clCreateKernel(...);
(9) Set kernel arguments
clSetKernelArg(...);
(10) Configure the work-item structure
size_t globalWorkSize[1];
globalWorkSize[0]=2048;
(11) Enqueue the kernel for execution
clEnqueueNDRangeKernel(...);
(12) Read output results to host
clEnqueueReadBuffer(...);
(13) Release OpenCL Resources
clRealeaseKernel(...);
clRealeaseProgram(...);
...
2013年3月20日 星期三
2013年3月13日 星期三
物件導向(1)
#include
<stdio.h> → include interface ↔ 沒有include
implementation
int
main()
{
printf(“Hello
World!\n”); → 第一個引數format
string
return
0;
}
preprocessing(macro)
→ compiling → linking (才需要知道implementation
函式庫)
static
dynamic
posix
(portable operation system interface)
包含各種platform的實作
#include
<stdio.h>
int
stk[100]; → scope的問題 加上static解決問題
int
sp = -1;
void
push(int x) → 兩個stack
的問題 float
double型別的stack問題
{ 沒有encapsulation的問題
stk[++sp]=x;
}
int
pop()
{
return
stk[sp--];
}
ADT(Abstract
Data Type)= Data + Operators(用來manipulate
Data操作)
C++克服C的地方
encapsulation
inheritance(reuse)
polymorphism(switch)
資料庫(3)
DB2
& SQL
每種query
language 都有DDL
and DML
a
base table is “real” table實體存在
a
view is a “virtual” table
2013年3月5日 星期二
OpenCL(1) vector add
//vector add 副程式 類似glsl中 fragment shader 和vertex shader呼叫方式
const char* programSource =
"__kernel \n"
"void vecadd(__global int *A,\n"
" __global int *B,\n"
" __global int *C) \n"
"{\n"
" // Get the work-item unique ID \n"
" int idx = get_global_id(0); \n"
"\n"
" // Add the corresponding locations of \n"
" // 'A' and 'B', and store the result in 'C'. \n"
" C[idx] = A[idx] + B[idx];\n"
"}\n"
;
main主程式
...
kernel = clCreateKernel(program, "vecadd", &status); //inline 方式call vecadd
...
Compile方法
g++ vectoradd.c -I/usr/local/cuda-5.0/include -L/usr/local/cuda-5.0/lib64 -lOpenCL
Compile方法
g++ vectoradd.c -I/usr/local/cuda-5.0/include -L/usr/local/cuda-5.0/lib64 -lOpenCL
資料庫(2)
第二章 Data
Model
Data
Model:A set of concepts to describe the structure of a database, and
certain constraints that the database should obey.
Components
of Data Model
1.Structures
2.Operations
3.Integrity
Constraints
Data
Model為了將資料抽象化,將storage
detail隱藏
Relational
Data Model
Hierarchical
Data Model
Network
Data Model
Primary
Key:滿足uniqueness和minimality的candidate
key
Foreign
key:a foreign key is an attribute of relation R2 whose values are
refer to the primary key of some relation R1.
資料庫(1)
第一章 Why using a DB?
Database System:DBMS+data
一個資料庫就是一群有關系的資料所成的集合
Operations on a DB
1.add/remove files
2.insert/delete/update data in existing files
3.retrieve data 最常用read-only (select)
field(attribute) → record(tuple) → file
一個資料庫系統能提供資料分享,整合,一致性,標準化,安全限制及避免重複資料的儲存
(ADV.)
1.Redundancy
2.Inconsistency(Avoided)
3.Shared
4.Standards
5.Security restrictions
6.Integrity
7.Conflicting requirements
8.Data Independence
an architecture for a DB
Three layers:Internal, Conceptual, External → 資料庫有三層
Internal schema → storage structures and access paths
Conceptual schema → structure and constraints
External schema → user views
1.Logical Data Independence
2.Physical data Independence
3.Mapping
Data Definition Language(DDL):Used by the DBA and database designer to specify the conceptual schema of a database.
Data Manipulation Language(DML):Used to specify database retrievals and updates.
DML commands(data sub-language)
Objects of Database Design
1.easy to use
2.easy to maintain
3.cost effective
2013年3月3日 星期日
安裝cuda 5.0 on Ubuntu 12.04
sudo ln -s /usr/lib/x86_64-linux-gnu/libglut.so /usr/lib/libglut.so
sudo ./cuda_5.0.35_linux_64_ubuntu11.10-1.run
export PATH=$PATH:/usr/local/cuda/bin:/usr/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64:/lib
訂閱:
文章 (Atom)