Linux programming-GPU computing

Source: Internet
Author: User
Linux programming-GPU computing-Linux general technology-Linux programming and kernel information. The following is a detailed description. For a brief introduction to brookgpu, see the following link:
Http://tech.sina.com.cn/c/2003-12-30/26206.html
This article translated an article about the brookgpu language on the Stanford University website. The original Article is:
Http://graphics.stanford.edu/projects/brookgpu/lang.html
For more information about the usage of brookgpu in the Community, see the following website:
Http://www.linuxfans.org/nuke/mo... op = geninfo & did = 2171
To use brookgpu, you need nvidia graphics card and cg driver.
Ftp://download.nvidia.com/develo... -1.2.1-Linux.tar.gz
The CG interface controls dia_drv.o, fglrx_drv.o, and via_drv.o. Therefore, GPU instances that can use the preceding three. o files are supported.

You are welcome to increase the test data and your understanding of brookgpu. The first time you translate a new technology, errors are inevitable. Please criticize and correct me more!
My mail: zhangyu9587@sina.com, welcome to contact me!

The language in which the video card replaces the CPU-about BrookGpu
Brook is an extension of the Standard ansi c language. It is an efficient language that people are familiar with. It integrates two features: Data Parallel Computing and arithmetic computing concentration.
The general computing model, also known as Stream, has the following advantages over conventional languages:
1. Data Parallelism: allows programmers to specify how to execute the same operation in parallel on different data.
2. Arithmetic computing set: programmers are encouraged to specify operations on the data to minimize global communication and maximize local computing!
For more information about Brook, see Merrimac web site, which includes a complete description of the language. To be used on GPUs, Brookgpu implements a subset of the Brook specification. A Brook program contains legal syntax extensions of C code and streams and functions called kernels.

Stream (Streams)
Stream is a new data type Extension, representing a series of data that can be processed in parallel. The Declaration Rules of Streams are similar to those of arrays and are declared using angle brackets. An example of declaring a stream is as follows:
Float s <10, 10>;
A two-dimensional floating point stream is declared above. Each stream is composed of flow elements. In the preceding example, s is a stream that contains 100 floating point stream elements. The stream shape refers to the dimension of the stream. In this example, the stream is 10x10. Stream is described in column-first mode, similar to arrays in C language. Therefore, the stream in the shape of <100> is equivalent to the stream in the shape of <1,100> and <100,>.
Although similar to the C array, the streams in Brookgpu differ from the arrays in C as follows:
1. Stream elements cannot be obtained by subscripts outside the kernels function (for example, s [3] [2]).
2. Static initialization of convection is not allowed, for example:
Float s <100 >={ 1.0f, 2.0f,...} is not allowed.
3. The stream must be a local variable (stack ).
4. The stream can only be read and written in the core (kernel) function, or data can be obtained from common pointers and versa through special operators.
StreamRead (s, data_s );
/* Use * Data stream s at data_s to assign values */
StreamWrite (s, data_s );
/* Use the data of stream s <> to assign values to * data_s */
Although this operation may be further optimized by the compiler, it is highly efficient to copy data to the stream.
For GPU-compiled code, the stream corresponds to the texture memory area of the Organization. The compiler can perform code stream analysis to better decide when and where to allocate the organizational memory (texture memory), or completely eliminate the need for temporary storage of stream variables. For convenience, brook also extends C to include float2, float3, and float4 as basic data types. These types are equivalent to the typedef structure (structs) in C. For example:
QUOTE:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.