November 2010

You are browsing the site archives by month.

Matrix-Matrix Multiplication MPI C Source Code

Expanding from my previous post, “Matrix-Vector Multiplication MPI C Source Code”. Now we create a program to calculate two two-dimensional matrices (array) with MPI. Same concept and algorithm with matrix-vector used to solve this problem, row-based operation.

Now the differences from matrix-vector just the array size and dimension.

#define AROW 3
#define ACOL 2

#define BCOL 3

#define MAX_VALUE 10

For proc_map() function please look at matrix-vector post, and here’s the computational code for matrix-matrix multiplication.

Read More →

Matrix-Vector Multiplication MPI C Source Code

Here’s my first task for MPI Programming. Create a matrix-vector multiplication program using Message Passing Interface. Let’s go directly to the source code and we can discuss it later if you want.

First, MPI with C language commonly use “mpi.h” and you still can use standard C library.

#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "math.h"

#include "mpi.h"

Now, we need to define the size of matrices, A as [AROW x ACOL] and B as [ACOL x 1] so the result let’s call it matrix C [AROW x 1]. Because the row of B must be equals with column of A and the result matrix C has row = AROW and single column. MAX_VALUE is the constant for defining maximum value of random number for matrices elements value.

#define AROW 3
#define ACOL 2

#define MAX_VALUE 10

proc_map() function is the function to map the each task to which process to do it.

/* Process mapping function */
int proc_map(int i, int size)
	size = size - 1;
	int r = (int) ceil( (double)AROW / (double)size);
	int proc = i / r;
	return proc + 1;

Read More →

Rounding Shapes SmallBasic Source Code

Hmm… there are some new programming language from Microsoft again, SmallBasic, i think it like be small edition of Visual Basic because the error checking or debugging use Visual Basic style. Okay this post is my sparetime work, i will put number of a shapes to create some circle-like shape. Start from line, triangle, square, until nearly-circle shape and look what the shapes looks like. Beautiful.

Read More →