[Home] [About] [Download] [Shaders] [Forum] [People] [SF Project]

About Sh

As mentioned elsewhere on this webpage, Sh is a metaprogramming language for programmable GPUs. Programmable GPUs are graphics processing units which allow almost arbitrary effects to be executed with extreme efficiency in the GPU rather than the CPU. In practice this offloads a lot of graphical processing to specialized hardware rather than software and allows the graphics card to be treated as a general-purpose secondary processor.

Sh, the high-level GPU programming language

Writing programs for these GPUs can be a tedious task, as it generally has to be done in assembly. A high-level language allows programming GPUs with familiar constructs and syntax, without worrying about the details of the hardware. A high-level language is also important for portability across different hardware and graphics API platforms. Sh is such a high-level language. It offers the convenient syntax of C++ and takes the burden of register allocation and other low-level issues away from the programmer. This allows GPU programs to be written much quicker and makes porting such programs extremely simple.

Sh, the metaprogramming language

Stages of Sh compilation

Sh is built on top of C++. This does not mean that programs using Sh must be written in C++. It just means that the syntax of the GPU programs themselves will be that of C++ programs. This has several convenient advantages:

One does not need to be aware of how Sh operates to use it, but the chart on the right might be useful in explaining its operation. First, Sh source code is compiled by the C++ compiler with the Sh library, since it is simply a C++ program. When the generated binary is executed, the Sh instructions do not take effect immediately. Instead the program is converted into an intermediate representation, as illustrated on the right. This intermediate representation is slightly higher-level than most GPU instruction sets, allowing it to be transformed into code for any particular GPU. The intermediate code can then be passed on to a backend (e.g. for the Sm simulator, or the OpenGL ARB_{fragment,vertex}_program extensions) and transformed into actual GPU assembly. This assembly can then either be stored and used later or immediately be sent to the GPU. The compilation process is fast enough to recompile the program (into Sh intermediate and real GPU code) every time the program runs, but this is not a necessity. Thus, the code could be stored instead and then used in a different program, which need not even be written in C++.

Sh, the research tool

Sh incorporates full language constructs for branching (e.g. for loops and if statements). Once GPUs are powerful enough to execute such constructs (which, to some extent, is true today) backends can be adjusted to compile such code to real hardware assembly. In the mean time our GPU simulator Sm implements various features expected to be in GPUs in the near future, such as a unified vertex and fragment instruction set.

We intend to add more interesting features to Sh relevant to GPU research, e.g. stream-processing models and texture-compression algorithms. These can then initially be supported by our simulator and later hopefully implemented in real GPUs. When these features are available, Sh will be ready to support them.

Sh, the Free Software project

Sh is released under the GNU Lesser General Public License. This allows anyone to view the source code, pass it on, improve it and use Sh in both Open-Source/Free Software and proprietary products under certain conditions.

The origin of Sh

Sh is the result of research at the University of Waterloo Computer Graphics Lab. Specifically the language was conceived by Michael McCool and implemented by several members of the CGL.

Copyright 2003-2010 Intel Corporation.