Message

Telkomsel 3445 Text Message

What the hell… Thursday evening, August 14, 2011 i got a message from 3445 telkomsel. It said that my phone bill already reached Rp. 770,079. First i think that message was system fault but after i checked again with *888# it said my bill already reached Rp. 900k OMG! The next thing that appear in my mind was the internet package so i checked it, “UL INFO” send to 3636 but it said that i didn’t registered any internet packages. That’s the problem, i still have a message that said i’m registered the unlimited internet packages until August 10th.

Next day, of course i’m going to telkomsel’s customer services, fortunately the CS said there is a system error so my bill will be recalculated and i can go home. Hwoa… that was a shocking messages i can’t imagine paying 900k just for a month for phone bill.

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 →

Hello World MPI C Source Code

Got something interesting, MPI (Message Passing Interface) is the language or library which needed to create parallel programming. So let’s start with the usual way to begin code, “Hello World”. This post will be show how to make the simplest MPI code in C language.

#include "stdio.h"
#include "mpi.h"
 
int main(int argc, char** argv)
{
    int rank;
    int size;
 
    /* Initialize MPI  */
    MPI_Init(&argc, &argv);
 
    /* Getting the World Size and Process Number (rank) */
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
    /* Routine for process 0 */
    if (rank == 0)
    {
        printf("P%d : I Found this world size is %d processesn", rank, size);
        printf("P%d : Hello World! This is process number %d writing!n", rank, rank);
    }
    /* Routine for process 1 */
    else if (rank == 1)
    {
        printf("P%d : I Found this world size is %d processesn", rank, size);
        printf("P%d : Hello World! This is process number %d writing!n", rank, rank);
    }
    /* Routine for Other Processes */
    else
    {
        printf("P%d : I'm Unused Process...n", rank);
    }
 
    /* End of MPI */
    MPI_Finalize();
    return 0;
}

Read More →