Skip to main content

LinAlg API: SIMD and Update 3

Posted by aschunkjava on September 8, 2007 at 4:28 AM PDT

LinAlg API: Milestone 1 update 3

Half a month ago i announced update 2 of Milestone 1 of the LinAlg API. Update 2 included some utility methods for Complex Numbers and some other helpful methods.

New Features

With update 3 i have added a method called Negate() to the Vector classes with which you can simply negate the component values of a Vector:

Vector3D x = new Vector3D(2, 3, 1);
x.Negate(); // = -2, -3, -1

This is also avaiable for 2D Vectors.I have also added some things to the Matrix class. With update 3 you can create a matrix from a two-dimensional array:

double[2][2] mat = {{2, 1}, {3, 1}};
Matrix m = new Matrix(mat); //create matrix from array

I have also added some operations for array based matrices like +, -, * etc.

The Complex class now contains methods to compute Complex numbers in trigonomial and Euler notation.

SIMD for LinAlg API

Besides these "raw" Java implementations i have developed a tiny C library to detect SIMD features on Intel and AMD CPUs. In my last Blog on SIMD i said that SIMD can process 2 DWORD values. This is not correct. In fact, with SIMD you can process up to 4 32 Bit DWORD values which means that SIMD works with 128 Bit sized registers. Thats why SIMD can perform i.g. certain Vector operations much faster than the normal CPU registers.

Another thing is that AMD produces 64 Bit processors only that support SSE so in the end, things are easier because i only need to check for SSE. I dont know if AMD still uses 3DNOW so the Programmers Manual of AMD only mentions SSE.

Basically, the C library i have developed consists of a few functions that call CPUID instruction and perform a few assembly operations. In General, all you have to do is to use the test and mov instruction to check i.g. if SSE or SSE3 is avaiable.

Update 3 of LinALg API will be available next week and i will also upload the C library and the GUI application. Note: the GUI application is written with MFC so it only works on Windows.

Related Topics >>