Skip to Content

Software

Posted in

I'm starting to release my programs under GPL. This book page consolidates all the software I release.

Latest software:
Linux Utility v0.1
Reversi in C++ v0.1
Reversi in Java v0.7a
Parallel Reversi in Java v0.8b
Reversi in C++ Benchmark v0.1
OpenMP Parallel Reversi in C++ Benchmark v0.2
Parallel Reversi in Java Benchmark v0.1

Check out my git repository for these software.

Compiling Ruby 1.9.1-p376 on Fedora 12

Posted in

Get the following errors while compiling Ruby 1.9.1-p376?

ossl_ssl.c: In function ‘ossl_sslctx_get_ciphers’:
ossl_ssl.c:626: error: ‘STACK’ undeclared (first use in this function)
ossl_ssl.c:626: error: (Each undeclared identifier is reported only once
ossl_ssl.c:626: error: for each function it appears in.)
ossl_ssl.c:626: error: expected expression before ‘)’ token
ossl_ssl.c:629: error: expected expression before ‘)’ token
ossl_ssl.c:629: error: too few arguments to function ‘sk_value’
ossl_ssl.c: In function ‘ossl_ssl_get_peer_cert_chain’:
ossl_ssl.c:1198: warning: passing argument 1 of ‘sk_num’ from incompatible pointer type
/usr/include/openssl/stack.h:79: note: expected ‘const struct _STACK *’ but argument is of type ‘struct stack_st_X509 *’
ossl_ssl.c:1201: warning: passing argument 1 of ‘sk_value’ from incompatible pointer type
/usr/include/openssl/stack.h:80: note: expected ‘const struct _STACK *’ but argument is of type ‘struct stack_st_X509 *’
ossl_ssl.c: In function ‘ossl_ssl_get_cipher’:
ossl_ssl.c:1223: warning: assignment discards qualifiers from pointer target type
make[1]: *** [ossl_ssl.o] Error 1

Try the patch in this post.

ruby-1.9.1-p376 $ tar zxf fix_stack_not_found.tgz
ruby-1.9.1-p376 $ cat fix_stack_not_found.patch | patch -p1
patching file ext/openssl/ossl.c
patching file ext/openssl/ossl_pkcs7.c
patching file ext/openssl/ossl_ssl.c

ruby-1.9.1-p376 $ make
...

The compilation is now able to complete. However, I didn't verify whether the SSL is working properly.

Trial: Mimetex with mathfilter

Posted in

ax^2 + bx + c = 0

x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}

Parallel QuickSort with OpenMP and Cilk++

The introduction of omp task in OpenMP 3.0 allows easy parallelization of the famous quick sort algorithm. As OpenMP 3.0 support in GCC is relatively new, I like to compare its performance particularly the omp task with a commercial compiler Cilk++ which is designed to efficiently support spawn/sync mechanism. Conceptually, the omp task and the Cilk++ spawn/sync are very similar.

Quick sort chooses a pivot, partitions elements into [< pivot] & [>= pivot], and sorts the two partitions recursively. The implementation in my experiment performs partitioning sequentially, and sorts the two resulting partitions in parallel.

Experiment setup:

  • AMD64 Phenom X4 9950 (2.6GHz)
  • Fedora 10 x86_64
  • GCC 4.4 svn revision 144773
  • Cilk++ 1.0.2

Parallelizing Recursive Fibonacci using OpenMP and Cilk++

OpenMP 3.0 has added an interesting construct called omp task, while Cilk++ is a compiler developed by Cilk Arts to easily parallelize a C/C++ program. It is interesting to see how we can parallelize the following simple fibonacci program.

Serial:

long fib_serial(long n)
{
    if (n < 2) return n;
    return fib_serial(n-1) + fib_serial(n-2);
}

Fedora 10 Problem: Cannot find CTL module "transform_RRT"

Posted in

On Fedora 64bit, exrdisplay is not able to display an .exr image.

$ exrdisplay lighting.exr 
Warning: Environment variable CTL_DISPLAY_TRANSFORM is not set; using default value ("transform_display_video").
Warning: Environment variable CTL_DISPLAY_CHROMATICITIES is not set; using default value (chromaticities according to Rec. ITU-R BT.709).
Warning: Environment variable CTL_DISPLAY_WHITE_LUMINANCE  is is not set; using default value (120 candelas per square meter).
Warning: Environment variable CTL_DISPLAY_SURROUND_LUMINANCE  is is not set; using default value (12 candelas per square meter).
Cannot find CTL module "transform_RRT".

Solution I: Set the CTL module path manually.

user$ CTL_MODULE_PATH=/usr/lib64/CTL exrdisplay lighting.exr

or

Solution II: Install the 32bit CTL library (OpenEXR_CTL-libs.i386)

root% yum install OpenEXR_CTL-libs.i386
user$ exrdisplay lighting.exr

or

Solution III: Link the expected CTL module path.

# This assumes the 32bit CTL library (OpenEXR_CTL-libs.i386) is not installed.
root% cd /usr/lib
root% ln -s ../lib64/CTL
user$ exrdisplay lighting.exr

Fedora 10 Problem: Broken XFCE Windows Manager

Posted in

After installing Fedora 10 with XFCE, when you try to customize your windows interface, you'll get the following:

"These settings cannot work with your current window manager (imsetting-xim)"

According to Fedora Project website, a bug in GTK2 is to blame. But we can't just wait for the bug to be fixed.

I simply use KDE display manager by setting /etc/sysconfig/desktop.

% cat /etc/sysconfig/desktop
DISPLAYMANAGER="KDE"

and restart your X windows (ctrl-alt-backspace) or restart your system.

Fedora 10 Problem: Cannot Type in Textbox in Java Applet

Posted in

Whether it is Sun Java plugin, IceTea plugin, I simply cannot type in a textbox of a Java applet. After much hacking, I found that scim-bridge is the one causing the problem. Killing off all the im-*, gconf-im-*, imsettings-xim, and scim-* processes immediately solves the problem.

I use scim-bridge because it can work with GTK or QT windows. Now looked like I can just use scim with GTK only.

Fedora 10 Problem: X is hogging CPU

Posted in

I installed Fedora 10 onto my system where the "nv" driver does not work with my display card GF 6600LM. The installation ends up being a text-based installation. Nvidia driver is later installed manually. Surprisingly, now the X windows take up the tty1 instead of usual tty7 (ctrl-alt F7).

The problem occurs when I start the system into runlevel 3 in console, then "init 5" to start X. The X process is then hogging the CPU.

The /var/log/message is showing something like below:

localhost /sbin/mingetty[2369]: tty1: invalid character 0x1f in login name

Now I find that mingetty keeps respawning tty1.

Solution:

Comment out everything in /etc/event.d/tty1 and forget about the existence of tty1.
Or find a way to get the X windows started back at tty7 (ctrl-alt F7).

Compiling VirtualBox 2.0.2 OSE in Fedora 9

Posted in

Unable to compile VirtualBox with the source package? Get errors like the following?

$ ./configure --with-gcc=gcc422 --with-g++=g++422
Checking for environment: Determined build machine: linux.amd64, target machine: linux.amd64, OK.
Checking for kBuild: found, OK.
Checking for gcc: Checking for as86: 
  ** as86 (variable AS86) not found!

Check if the following work helps. ;)

# Install necessary packages, including the following but not exhausive list. This requires root.
% yum install dev86 iasl pulseaudio-devel pulseaudio-libs-devel glibc-devel.i386 libX11-devel.i386 libXt-devel.i386 libXext-devel.i386 libXmu-devel.i386 compat-gcc-34 compat-gcc-34-c++ kernel-devel kernel-headers libxml2-devel libxslt-devel SDL-devel python-devel

# Obtain the source from http://www.virtualbox.org/wiki/Downloads

# Prepare and compile the source.
$ tar jxvf VirtualBox-2.0.2-OSE.tar.bz2
$ cd VirtualBox-2.0.2
$ ./configure --with-gcc=gcc34 --with-g++=g++34    # I was able to build with gcc424 and g++424 too.
$ source env.sh
$ kmk    # This compiles the VirtualBox. You may do 'kmk -j 4' if you have a quad-core processor.
$ cd ./out/linux.ARCH/release/bin/src    # ARCH depends on the architecture of your system.
$ make    # This build the kernel module vboxdrv.
% make install    # Requires root, to copy vboxdrv.ko to /lib/modules/`uname -r`/misc/vboxdrv.ko

# Load the VirtualBox kernel module.
% modprobe vboxdrv    # Requires root.

# Create a group of users for accessing the VirtualBox.
% groupadd vboxusers    # Requires root.
% chown root.vboxusers /dev/vboxdrv
% usermod -a -G vboxusers USERNAME    # USERNAME is your account username who should have accesses to VirtualBox.

# Logout and login for the group information to get updated.
# Check if your user is in group vboxusers.
$ groups    # This should show at least vboxusers

# Try running your newly built VirtualBox.
$ cd VirtualBox-2.0.2/out/linux.ARCH/release/bin
$ LD_LIBRARY_PATH=. ./VirtualBox

If you get the following error (happens in version 2.0.2),

VirtualBox: SUPR3HardenedMain: effective uid is not root (euid=500 egid=501 uid=500 gid=501)

try

% cd VirtualBox-2.0.2/out/linux.ARCH/release/bin
% chmod +s VirtualBox VBoxSDL VBoxHeadless

Save the script below to /etc/init.d/vbox and make sure it's executable. The script helps to load and unload the kernel module during system boot up and shutdown.

#!/bin/bash
### BEGIN INIT INFO
# Provides: vbox
# Required-Start: $syslog $local_fs
# Required-Stop: $syslog $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The Virtual Box kernel module
# Description: The Virtual Box kernel module
### END INIT INFO

start () {
        echo -n $"Starting Virtual Box: "
        modprobe vboxdrv
        sleep 1
        [ -c /dev/vboxdrv ] && chown root.vboxusers /dev/vboxdrv && echo " OK"
        [ ! -c /dev/vboxdrv ] && echo "Failed"
        return 0
}

stop () {
        echo -n $"Stopping Virtual Box: "
        [ -c /dev/vboxdrv ] && rmmod vboxdrv && echo " OK"
        [ ! -c /dev/vboxdrv ] && echo
        return 0
}

restart() {
        stop
        start
}

case $1 in
        start)
                start
        ;;
        stop)
                stop
        ;;
        restart)
                restart
        ;;
        status)
                [ -c /dev/vboxdrv ] && echo "Virtual Box is loaded"
                [ ! -c /dev/vboxdrv ] && echo "Virtual Box is not loaded"
        ;;
        *)

        echo $"Usage: vbox {start|stop|restart|status}"
        exit 3
esac

exit 0

Then,

% chkconfig --add vbox    # Add vbox as a service.
% service vbox status    # Check if the Virtual Box module is loaded.
% service vbox start    # Load the Virtual Box kernel module.
% service vbox stop    # Unload the Virtual Box kernel module.

Though the script is rather ugly, it should work ok for our purpose.

Syndicate content