Hi all,

I am new to minix3. I admired its fast booting and design filosophy. I

was searching

for alternatives for my everyday developing and computing because I

have the feeling

that Linux is becoming more and more chaotic. So I installed minix3 and

went ahead

to measure its performance on scientific computing codes which are

really numerically

intesive codes.

I tried to run a piece of code I wrote to test how minix3 would

perform. This piece of code

is one of the most basic kernels of numerical methods for solving large

sparse systems

of equations using iterative methods, and I use it from time to time

for testing new OS.

It performs a sparse matrix vector multiplication.

This forum doesn't give me the opportunity to attach any files so I

will just copy paste the

code and the file I used. The minix3 performance was awful as it

concerns the multiplication,

part. The reading of the matrix was slighlty worse than that of Linux

and this is affordable

because the filesystems have different architecture.

I compiled with:

# gcc -O2 sparsematrixbench-minix.c -o run

and then run the command:

#./run matrix.txt 1000000

The last number is the number of iterations the mutliplication should

be repeated. Below you can

take a look at the results; the numbers represent milliseconds.

multiplication

Linux: 35

minix3: 1033

As you see the difference is dramatic. Moreover with a very large

matrix of 20604953 bytes

minix spits a memory fault error, while with smaller matrices 5031972

bytes and less it

does fine. I am attaching the matrix file I used for the test. If

somebody is interested could

you tell me please where can I attach the big matrix .tar.bz2 such that

you can track the

problem for yourself?

### file matrix.txt ###

# exclude this header from the file such that the first line in the

file

# starts with the numbers below

3

3

5

0

2

4

5

0

2

1

2

2

1

1

2

2

3

And below you can see the code I used:

// file sparsematrixbench-minix.c

#include <stdio.h>

#include <stdlib.h>

#include "sys/time.h"

typedef struct

{

int nrows;

int ncols;

int nonzeros;

int* pRows;

int* pCols;

double* pData;

} SparseMatrix;

typedef struct

{

struct timeval begin;

struct timeval end;

/* struct timezone zone; */

double timePassed;

} TimeStruct;

void tick(TimeStruct* ts)

{

/* gettimeofday(&ts->begin, &ts->zone); */

gettimeofday(&ts->begin, NULL);

}

void tack(TimeStruct* ts)

{

/* gettimeofday(&ts->end, &ts->zone); */

gettimeofday(&ts->end, NULL);

ts->timePassed =

1000.0 * (ts->end.tv_sec - ts->begin.tv_sec) +

(ts->end.tv_usec - ts->begin.tv_usec) / 1000.0;

}

void timeNeeded(TimeStruct* ts, const char* label)

{

printf("%s took %8.4f milliseconds\n", label, ts->timePassed);

}

void init(SparseMatrix* pmatrix, char* filename)

{

int i;

/* open the filename */

FILE* matrixfile;

matrixfile = fopen(filename, "r");

if (matrixfile == (FILE*) NULL)

{

printf("File I/O Error: Cannot access file %s.\n", filename);

return ;

}

printf("Opening %s ...\n", filename);

/* read nrows, ncols, nonzeros */

char numberstr[80];

fgets(numberstr, 80, matrixfile);

sscanf(numberstr, "%d", &pmatrix->nrows);

fgets(numberstr, 80, matrixfile);

sscanf(numberstr, "%d", &pmatrix->ncols);

fgets(numberstr, 80, matrixfile);

sscanf(numberstr, "%d", &pmatrix->nonzeros);

pmatrix->pRows = (int*) malloc((pmatrix->nrows+1)*sizeof(int));

pmatrix->pCols = (int*) malloc(pmatrix->nonzeros*sizeof(int));

pmatrix->pData = (double*)

malloc(pmatrix->nonzeros*sizeof(double));

printf("reading row pointers\n");

/* read the row index pointer pRows */

for (i = 0; i < pmatrix->nrows+1; i++)

{

fgets(numberstr, 80, matrixfile);

sscanf(numberstr, "%d", &pmatrix->pRows[i]);

}

printf("reading columns\n");

/* read the column index pointer pCols */

for (i = 0; i < pmatrix->nonzeros; i++)

{

fgets(numberstr, 80, matrixfile);

sscanf(numberstr, "%d", &pmatrix->pCols[i]);

}

printf("reading nonzeros\n");

/* read the data index pointer pData */

for (i = 0; i < pmatrix->nonzeros; i++)

{

fgets(numberstr, 80, matrixfile);

sscanf(numberstr, "%lf", &pmatrix->pData[i]);

/* printf("[%d] %lf\n", i, pmatrix->pData[i]);*/

}

printf("nonzeros read successfully\n");

/* close file */

fclose(matrixfile);

printf("file read succesfully\n");

}

void multiply(SparseMatrix* pmatrix, double* x, double* b)

{

double sum;

int i, j, index, from, to, n;

n = pmatrix->nrows;

for (i = 0; i < n; i++)

{

from = pmatrix->pRows[i];

to = pmatrix->pRows[i+1];

sum = 0.0;

for (index = from; index < to; index++)

{

j = pmatrix->pCols[index];

sum += pmatrix->pData[index]*x[j];

}

b[i] = sum;

}

}

void release(SparseMatrix* pmatrix)

{

free(pmatrix->pRows);

free(pmatrix->pCols);

free(pmatrix->pData);

}

int main(int argc, char** argv)

{

if (argc != 3)

{

printf("usage: %s sparsematrixfile iterations\n", argv[0]);

exit(1);

}

/* for timing purposes */

TimeStruct secs;

/* declare a new SparseMatrix object */

SparseMatrix matrix;

/* this is the vector the matrix is applied on */

double* x;

/* and this is the vector which holds the result of the */

/* multiplication */

double* b;

/* this variable holds the dimension of the matrix */

int i, iter, n;

/* this variable suggest how many times the multiplication will be

*/

/* repeated */

int iters;

/* initialize the matrix from the input file */

tick(&secs);

init(&matrix, argv[1]);

tack(&secs);

timeNeeded(&secs, "sparse matrix file reading");

/* retrieve the number of iterations from the command line */

iters = (int) strtol(argv[2], NULL, 0);

/* retrieve the leading dimension of the matrix */

n = matrix.nrows;

/* allocate memory for the vectors */

x = (double*) malloc(n*sizeof(double));

b = (double*) malloc(n*sizeof(double));

/* initialize the vector x by arbitrary numbers */

for (i = 0; i < n; i++)

{

x[i] = 3.0*(double)i+2.0;

}

/* perform multiplication #iter times */

tick(&secs);

for (iter = 0; iter < iters; iter++)

{

multiply(&matrix, x, b);

}

tack(&secs);

timeNeeded(&secs, "sparse matrix vector multiplication");

free(b);

free(x);

release(&matrix);

return 0;

}

Cheers!

Archwn.