Japanese

Use SSE instructions on FreeBSD


Notice

This patch has already been marged to FreeBSD since 4.4-RELEASE.

What's New?

Wed Jun 20 17:25:02 JST 2001 / sys-r500-SSE-2.diff.gz
SSE support patch for FreeBSD 5.0-CURRNET (2001/06/20) is available.
Fri Mar 2 21:02:20 JST 2001 / sys-r500-SSE-1.diff.gz
SSE support patch for FreeBSD 5.0-CURRNET (2001/02/28) is available.
Wed May 17 00:07:40 GMT 2000 / sys-r400-SSE-5.diff.gz
Support mulitprocessor systems.
Submitted by Takekazu KATO <kato@chino.it.okayama-u.ac.jp>

Background

Intel ® introduces some instructions to IA-32 processors, when they release Pentium ® III processor, which is called SSE (Streaming SIMD Extensions.) These extensions are combined with a sigle instruction stream, multiple data stream (SIMD) model, which means we may operate multiple data at once. SSE may accelarate the performance of applications, especially using floating point operations.

To use SSE, we, at least, need an assembler that can handle SSE instructions, and some Operating System support as follows:

  1. Set control register to enable SSE (Set bit 25 and 26 to 1 on %cr4).
  2. Save and restore SSE registers, when OS switches process context.
  3. Write an exception handler.

GNU binutils 2.10 supports SSE, but FreeBSD kernel has not supported SSE yet.

Patches

These patches provide basic support to use SSE instruction on FreeBSD box. They seem to work on both FreeBSD 4.0-RELEASE and FreeBSD 5.0-CURRENT (2001/02/28).

How to use it?

  1. Rebuild GNU as to be able to handle SSE instructions.
    Note: FreeBSD 4.0-RELEASE only. If you use FreeBSD 5.0-CURRENT, you must ignore this.
    # cd /usr/src/contrib/binutils
    # zcat /some/where/binutils-291-SSE.diff.gz | patch -p2
    # cd /usr/src/gnu/usr.bin/binutils
    # make install
    	
  2. Apply the patch to kernel source.
    # cd /sys
    # zcat /some/where/sys-rXXX-SSE-X.diff.gz | patch -p2
    	
  3. Add "options CPU_ENABLE_SSE" to your kernel configuration file, and rebuild kernel.
    # cd /sys/i386/conf
    # echo 'options CPU_ENABLE_SSE' > MYKERNEL
    # config MYKERNEL
    # cd ../../compile/MYKERNEL
    # make depend; make
    	
  4. Install new kernel and reboot.
    # make install
    # sync ; sync ; sync
    # shutdown -r now
    	
  5. Check hw.instruction_sse kernel variable. If it is 1, SSE instruction support is enabled on your kernel.
    % sysctl hw.instruction_sse
    hw.instruction_sse: 1
    	

TODO

  1. Exception handling.

Related Links


Copyright © 2000, 2001
Issei Suzuki <issei@issei.org>