Saturday, July 14, 2012

Integration of SQLite3 and Netbeans C/C++ IDE

Few days back, I wanted to use SQLite database for one of my project. I spend couple of hours to find a way to integrate with Netbeans. Maybe many of us will be clever enough to just follow the information given on SQLite website to accomplish this task, but people like me can follow this blog post :)
I am using Netbeans C/C++ IDE ver. 7.1.2 and SQLite ver. 3.7.13 and Windows 7 OS.


Download links for:
I hope, all above files are being downloaded in one folder for future use or give away to others :P

Installation Procedure:
Installation of Cygwin, Netbeans, and SQLite Database browser is straight forward, hopefully for everyone. But in order to install SQLite source code that we downloaded before, need procedure given below.

Compile SQLite using Cygwin:
Open Cygwin Terminal, then;
  1. Locate Z:\Cygwin\home\your_name. 'Z' is the drive name where Cygwin is installed, and 'your_name' is YOUR NAME :P.
  2. Copy source code file 'sqlite-autoconf-3071300.tar.gz' to directory mentioned in point 1.
  3. Start Cygwin.
  4. Enter into Z:\Cygwin\home\your_name. By default, Cygwin terminal is in home\your_name directory. You can check using 'pwd' command, if response is negative then use 'cd' to change directory.
  5. tar -xzvf sqlite-autoconf-3071300.tar.gz (To unzip)
  6. Enter sqlite-autoconf-3071300, e.g. cd sqlite-autoconf-3071300. Then
  7. ./configure
  8. make
  9. make install
Great, we compiled the SQLite, but what we are interested in are two library files which are located in C:\cygwin\usr\local\lib, and SQLite3 Header file located in C:\cygwin\usr\local\include. These header and library files will be used in linking Netbeans project with SQLite database;
  • sqlite3.h
  • libsqlite3.a
  • libsqlite3.dll.a
Include Header and Library files in Netbeans:
  • Include header file; #include <sqlite3.h>
  • Go to project settings of your Netbeans project. Then 'build->linker->libraries', and give reference to above two libraries.
And we are done here, now we can write queries and access database using C/C++ code.

Thursday, November 17, 2011

SESC: Simulator Configuration with CMP

Note: I am using LINUX with following specifications, g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1.

Installing SESC first time, then follow this post SESC Simulator: First Time Installation for instructions.

Building SESC:
Make new directory ‘buildcmp’ in ‘sesc’ folder;
Simulator can be configured as many set of operations, so recommendation is to create different ‘build’ directory for each configuration.
> mkdir buildcmp
> cd buildcmp

Configuring SESC For SMP:

> ../sesc/configure --enable-smp

Executable SESC with SMP:

> make
’sesc.smp’ is the executable file for further testing. 

Configuration File:
In case, you want to test simulator with CMP configurations without changing any parameter, there is one file ‘cmp.conf’ present in ‘/sesc/confs/’ folder.

Copy cmp.conf and shared.conf file in the build folder;
> cp ../sesc/confs/cmp.conf /home/user/build/
> cp ../sesc/confs/shared.conf /home/user/build/

Running FFT Benchmark:
There are few benchmark applications are available in ‘/sesc/tests/’ folder to test previously build simulator. While running this test simulation, crafty benchmark is used. 
> ./sesc.smp -c cmp.conf ../sesc/benchmark/fft.mips

Output:
The generated simulator output file will be with the name ‘sesc_fft.xxxxxx’. The extension ‘xxxxxx’ is random and will be different every time benchmark is tested.

static[0x1006b810-0x10085ec4] heap[0x10086000-0x18086000] stack[0x18086000-0x1887e000] -> [0xae000000-0xb68127f0]

FFT with Blocking Transpose
   1024 Complex Doubles
   1 Processors
   65536 Cache lines
   16 Byte line size
   4096 Bytes per page

                 PROCESS STATISTICS
            Computation      Transpose     Transpose
 Proc          Time            Time        Fraction
    0                66             13       0.19697

                 TIMING INFORMATION
Start time                                 :       1735893725
Initialization finish time              :       1735893730
Overall finish time                     :       1735893796
Total time with initialization       :               71
Total time without initialization  :               66
Overall transpose time             :               13
Overall transpose fraction        :          0.19697

SPLASH2 Benchmarks:
SPLASH2 Benchmark consists of different applications that can be run on SESC Simulator in order to evaluate cycles, power, and energy performance according to the parameters set in configuration file (sesc.conf).
Download Splash2 Benchmark Kernels Applications.

Other Links:

Monday, November 7, 2011

SESC: Simulator Configuration with Power Model SMP

Note: I am using LINUX with following specifications, g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1.

Installing SESC first time, then follow this post SESC Simulator: First Time Installation for instructions.

Building SESC:
Make new directory ‘build’ in ‘sesc’ folder;
Simulator can be configured as many set of operations, so recommendation is to create different ‘build’ directory for each configuration.
> mkdir build
> cd build


Configuring SESC For SMP:

> ../sesc/configure --enable-smp --enable-power


Executable SESC with SMP:

> make
’sesc.smp’ is the executable file for further testing. 


Configuration File:

In case, you want to test simulator with SMP configurations without changing any parameter, there is one file ‘smp.conf’ present in ‘/sesc/confs/’ folder.

Copy smp.conf and shared.conf file in the build folder;
> cp ../sesc/confs/smp.conf /home/user/build/
> cp ../sesc/confs/shared.conf /home/user/build/

Rename ‘smp.conf’ with ‘sesc.conf’.


Compilation SESC with Power Model:

‘cactify’ and ‘wattchify’, two executables are required for power and energy calculation.
  • 'cactify'; for clock frequency, capacitance and power calculation
  • 'wattchify'; for energy calculation
To generate executable, following commands are required;
> make cactify
> make wattchify

To obtain, power model based on the configuration file;
> ./wattchify sesc.conf tmp.conf
> ./cactify tmp.conf power.conf

‘power.conf’ is the simulator output file.

Running Benchmark:
There are few benchmark applications are available in ‘/sesc/tests/’ folder to test previously build simulator. While running this test simulation, crafty benchmark is used. 
> ./sesc.smp -h0x800000 -cpower.conf ../sesc/tests/crafty < ../sesc/tests/tt.in

Output:
The generated simulator output file will be with the name ‘sesc_crafty.xxxxxx’. The extension ‘xxxxxx’ is random and will be different every time benchmark is tested.

static[0x1008db40-0x101b3dd4] heap[0x101b4000-0x109b4000] stack[0x109b4000-0x111ac000] -> [0xb6000000-0xb711e4c0]

Crafty v14.3

sesc_simulation_mark 0 (simulated) @32112426
White(1): sesc_simulation_mark 1 (simulated) @32183488
White(1): pondering disabled.
sesc_simulation_mark 2 (simulated) @32269704
White(1): noise level set to 0.
sesc_simulation_mark 3 (simulated) @32297868
White(1): search time set to 99999.00.
sesc_simulation_mark 4 (simulated) @32423267
White(1): verbosity set to 5.
sesc_simulation_mark 5 (simulated) @32447392
White(1): sesc_simulation_mark 6 (simulated) @32908293
White(1): search depth set to 2.
sesc_simulation_mark 7 (simulated) @32920437
White(1): 
              clearing hash tables

              depth   time  score   variation (1)
                1   ###.##  -0.67   axb5 c6xb5
                1   ###.##  -0.08   a4a5
sesc_simulation_mark 8 (simulated) @37373970
                1-> ###.##  -0.08   a4a5
                2   ###.##     --   a4a5
                2   ###.##  -0.65   a4a5 f6f5
                2   ###.##  -0.58   axb5 c6xb5 Ne4c5
                2   ###.##  -0.46   Rf1c1 f6f5
                2   ###.##  -0.43   Ra1c1 f6f5
sesc_simulation_mark 9 (simulated) @41424941
                2-> ###.##  -0.43   Ra1c1 f6f5
              time:###  cpu:###  mat:-1  n:833  nps: ####
              ext-> checks:18 recaps:4 pawns:0 1rep:6
              predicted:0  nodes:833  evals:372
              endgame tablebase-> probes done: 0  successful: 0
              hashing-> trans/ref:17%  pawn:83%  used:w0% b0%

White(1): Ra1c1 
              time used: ###.##
sesc_simulation_mark 10 (simulated) @42650164
Black(1): execution complete.
Segmentation fault

Note: Till now, I am unable to figure it out that why there is segmentation fault after the end of execution (If anyone know, please let me know as well). Apart from segmentation fault occurrence, the simulator output file ‘sesc_crafty.xxxxxx’ is valid to generate report file.

Generating Report:
There is ‘report.pl’ script file located in ‘/sesc/scripts/’ folder, is to view the outcome of the benchmark.
Keep in mind that we are still in build directory, that we created in the start. So, by executing the following command;
> ../sesc/scripts/report.pl -last

Customization of Configuration File:
Th configuration file ('sesc.conf') contain design parameters; which can be changed to test simulation performance, for example;
  • Number of Processors [2-32]
  • Processor Issue Width [1-8]
  • L1 Instr. Cache Size [2048-16384]
  • L1 Data Cache Size [2048-16384]
  • L2 Private Cache Size [32768-262144]
  • L1 Instr. Cache Associativity [1-8]
  • L1 Data Cache Associativity [1-8]
  • L2 Data Cache Associativity [1-8]
  • I/D/L2 Cache Block Size [16-32]
After changing the configuration file, power model will be achieved by running the following commands at every change of configuration;
> ./wattchify sesc.conf tmp.conf
> ./cactify tmp.conf power.conf

SPLASH2 Benchmarks:
SPLASH2 Benchmark consists of different applications that can be run on SESC Simulator in order to evaluate cycles, power, and energy performance according to the parameters set in configuration file (sesc.conf).
Download Splash2 Benchmark Kernels Applications.

Other Links:

SESC Simulator: First Time Installation

Note: I am using LINUX with following specifications, g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1.

SESC: Cycle Accurate Architectural Simulator is the official website for SESC Simulator which contains; documentation, SescUtils Package informaiton.

Downloading SESC:
To download pre-compiled binaries of SESC Simulator, use the following instructions in LINUX Shell.
  • > sudo cvs -d:pserver:anonymous@sesc.cvs.sourceforge.net:/cvsroot/sesc login (When password is requested, just press enter) 
  • > cvs -z3 -d:pserver:anonymous@sesc.cvs.sourceforge.net:/cvsroot/sesc co -P sesc (By default, ‘sesc’ folder will be checked out in home folder)
Requirements:
  • Be sure that flex and bison is already installed 
  • > sudo apt-get install zlib1g-dev 
Building SESC:
Make new directory ‘build’ in ‘sesc’ folder;
Simulator can be configured as many set of operations, so recommendation is to create different ‘build’ directory for each configuration.
> mkdir build
> cd build

Configuring SESC:
SESC provides different configuration options, which can be checked using the following command;
> ../sesc/configure --help

Without any simulator configuration option, by default, all sesc directories are build.
> ../sesc/configure
> make

Errors during ‘make’:
  • ‘USHRT_MAX’ was not declared in this scope in [/sesc/src/libcore/FetchEngine.cpp and /sesc/src/libcore/Cluster.cpp] 
          Sol: Add #include <limits.h>
  • linux/dirent.h: No such file or directory in [/sesc/src/libmint/subst.cpp] 
          Sol: Change #include <linux/dirent.h> to #include <dirent.h>
  • ‘LONG_MAX’ was not declared in this scope, ‘uint32_t’ was not declared in this scope in [/sesc/src/libsuc/Config.cpp] 
          Sol: Add #include <limits.h>, Add #include <stdint.h>
  • ‘/usr/bin/ld’: cannot find -lz” 
          Sol: sudo apt-get install zlib1g-dev

Executable SESC:
> make sesc
’sesc.mem’ is the executable file for further testing.

Test Simulation with Crafty Benchmark:
There are few benchmark applications are available in ‘/sesc/tests’ folder to test previously build simulator. While running test simulation, by default, crafty benchmark is used.
> make testsim

Output:
The generated simulator output file will be with the name ‘sesc_crafty.xxxxxx’. The extension ‘xxxxxx’ is random and will be different every time benchmark is tested.

cp /home/user/build/../sesc/confs/mem.conf sesc.conf
cp /home/user/build/../sesc/confs/shared.conf .
./sesc.mem -h0x800000 -csesc.conf /home/user/build/../sesc/tests/crafty < /home/user/build/../sesc/tests/tt.in
static[0x1008db40-0x101b3dd4] heap[0x101b4000-0x109b4000] stack[0x109b4000-0x111ac000] -> [0x41000000-0x4211e4c0]

Crafty v14.3

sesc_simulation_mark 0 (simulated) @30176688
White(1): sesc_simulation_mark 1 (simulated) @30226193
White(1): pondering disabled.
sesc_simulation_mark 2 (simulated) @30297416
White(1): noise level set to 0.
sesc_simulation_mark 3 (simulated) @30320969
White(1): search time set to 99999.00.
sesc_simulation_mark 4 (simulated) @30423178
White(1): verbosity set to 5.
sesc_simulation_mark 5 (simulated) @30448529
White(1): sesc_simulation_mark 6 (simulated) @30749553
White(1): search depth set to 2.
sesc_simulation_mark 7 (simulated) @30765858
White(1): 
              clearing hash tables

              depth   time  score   variation (1)
                1   ###.##  -0.67   axb5 c6xb5
                1   ###.##  -0.08   a4a5
sesc_simulation_mark 8 (simulated) @33088274
                1-> ###.##  -0.08   a4a5
                2   ###.##     --   a4a5
                2   ###.##  -0.65   a4a5 f6f5
                2   ###.##  -0.58   axb5 c6xb5 Ne4c5
                2   ###.##  -0.46   Rf1c1 f6f5
                2   ###.##  -0.43   Ra1c1 f6f5
sesc_simulation_mark 9 (simulated) @37835514
                2-> ###.##  -0.43   Ra1c1 f6f5
              time:###  cpu:###  mat:-1  n:833  nps: ####
              ext-> checks:18 recaps:4 pawns:0 1rep:6
              predicted:0  nodes:833  evals:372
              endgame tablebase-> probes done: 0  successful: 0
              hashing-> trans/ref:17%  pawn:83%  used:w0% b0%

White(1): Ra1c1 
              time used: ###.##
sesc_simulation_mark 10 (simulated) @38876221
Black(1): execution complete.

Reports:
The generated output file in the previous step is based on type of configuration file. By changing parameters in the configuration file, the output file will be different.
There is ‘report.pl’ script file located in ‘/sesc/scripts/’ folder, is to view the outcome of the benchmark.
Keep in mind that we are still in build directory, that we created in the start. So, by executing the following command;
> ../sesc/scripts/report.pl -last

The detailed information based on the configuration file will be visible in the terminal. But by changing the script file, we can manage to write the output in text file as well.

Other Links:

Wednesday, November 2, 2011

SESC: Splash2 Benchmark Compilation Issue Resolved

I am using LINUX with following specifications, g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

After spending sometime, I am able to compile Splash2 Benchmark kernel applications with small modification in makefile of each application.

To download Splash2 benchmark, click -- > SESC: Splash2 Benchmark Kernels & Applications Package

Modification in Makefile of Each Kernel Application:
CFLAGS = -O2 -Olimit 2000 -w
LDFLAGS = -lmpc -lm

Replace the above two lines with
CFLAGS = -O2 -w
LDFLAGS = -lm

Then, run make to get the executable files e.g. CHOLESKY, FFT, LU, and RADIX.

To check associated parameters with each application, run the following command.
> ./CHOLESKY -h
> ./FFT -h
> ./LU -h
> ./RADIX -h

Rest of the work is all yours :)



Other Links:

Tuesday, November 1, 2011

SESC: SuperESCalar Simulator Initial Starting Guide

Many of us has problems in order to get started with SESC Simulaor, because there is not too much information available on the web and if there is some information then it is not at one place. So, we have to spend like hours to get tune with SESC to start our work.

The in depth document about SESC Simulator.

SESC: SuperESCalar Simulator

If viewers want to share information or facing problems, we can at least try to solve together :)


Other Links:

SESC: Splash2 Benchmark Kernels & Applications Package

SPLASH -- "Stanford Parallel Applications for Shared Memory"

Splash benchmark suite, developed by group of people working in Stanford University, contains kernels and applications  for multiprocessor systems performance check.

Kernels:
Complex 1D FFT
Blocked LU Decomposition
Blocked Sparse Cholesky Factorization
Integer Radix Sort

Applications:
Barnes-Hut
Adaptive Fast Multipole
Ocean Simulation
Hierarchical Radiosity
Ray Tracer
Volume Renderer
Water Simulation with Spatial Data Structure
Water Simulation without Spatial Data Structure

Download Splash2 Package:
> cd ~/benchmarks
> mkdir splash2
> cd splash2
> wget http://www-flash.stanford.edu/apps/SPLASH/splash2.tar.gz
> tar -xzf splash2.tar.gz

For sure after downloading Splash2 benchmark files, you need to compile it too in order to use for your work and for further development purposes.
If you need Pre-compiled Binaries of Splash2 benchmark, you can write me Email or from my GoogleDrive. You can check this page to solve compilation problems, click --> SESC: Splash2 Benchmark Compilation Issue.

Monday, September 12, 2011

Integration of BOSCH BMP085 using JENNIC 2-wire serial interface (I2Ccompatible) on JN-5148

The article describes use of Jennic hardware API library (AppHardwareApi_JN514x.h) for reading and writing data from the BOSCH BMP085 temperature and pressure sensor.

Hardware Description:
- The Jennic JN-5148 provides 2-wire synchronous serial interface, following I2C protocol, containing two lines of SCL (Serial Clock Line) connected to DIO14 and bi-directional SDA (Serial Data Line) connected to DIO15. The detailed description of Jennic Serial Interface and associated functions can be found at http://www.jennic.com/files/support_files/JN-UG-3066-Integrated-Peripherals-API.pdf.

- The BOSCH BMP085 consists of SCL (Serial Clock Line) connected to pin 6 and bi-directional SDA (Serial Data Line) connected to pin 7. The comprehensive description of BMP085 can be found at http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf.

Protocol Implementation Algorithm:
Major focus of this article is on how to communicate with BMP085 in order to read/write operations, and mathematical calculations for temperature and pressure can be found in the datasheet of BMP085.
Implementation is based on configuring Jennic as Master without interrupts enable and BMP085 as Slave device. The operational frequency 100 kHz is derived from Jennic system clock of 16 MHz by using pre-defined formula,

Operational Frequency = 16/[(Prescaler + 1) * 5]

Steps:
  • Jennic as Master Device and BMP085 as Slave Device configuration
  • Read calibration data from E2PROM of BMP085 for temperature and pressure
  • Reading and calculation of temperature
  • Reading and calculation of pressure
  • Resolution of output data is; Pressure – 0.01 hPa, and Temperature – 0.1 ˚C
Associated Jennic Functions:
  • void vAHI_SiMasterConfigure (bool_t bPulseSuppressionEnable, bool_t bInterruptEnable, uint8 u8PreScaler);
  • void vAHI_SiMasterWriteSlaveAddr (uint8 u8SlaveAddress, bool_t bReadStatus);
  • bool_t bAHI_SiMasterSetCmdReg (bool_t bSetSTA, bool_t bSetSTO, bool_t bSetRD, bool_t bSetWR, bool_t bSetAckCtrl, bool_t bSetIACK);
  • bool_t bAHI_SiMasterPollTransferInProgress (void);
  • void vAHI_SiMasterWriteData8 (uint8 u8Out);
  • uint8 u8AHI_SiMasterReadData8 (void);
Reading/Writing data from BMP085:
From the datasheet the BMP module address LSB distinguishes between read (1) and write (0) operations, corresponding to address 0xEF (read) and 0xEE (write). Where 0x77 is the BMP085 device address which will be Slave address.

// Sensor Address - Write Operation
uint8 BMP085_W = 0xEE;
// Sensor Address - Read Operation
uint8 BMP085_R  = 0xEF;

PRIVATE void vI2CRead (uint8 u8ReadAddress, uint8* u8DataOut, uint8 u8Length)
{
          uint8 i = 0;
          uint8 u8ReadLength;
          bool_t bFlag = FALSE;
          u8ReadLength = u8Length;
          vAHI_SiMasterWriteSlaveAddr (BMP085_W>>1, FALSE); // FALSE - Write Operation
          bFlag = bAHI_SiMasterSetCmdReg (E_AHI_SI_START_BIT,
                                                                      E_AHI_SI_NO_STOP_BIT,
                                                                      E_AHI_SI_NO_SLAVE_READ,
                                                                      E_AHI_SI_SLAVE_WRITE,
                                                                      E_AHI_SI_SEND_ACK,
                                                                      E_AHI_SI_NO_IRQ_ACK);
          while(bAHI_SiMasterPollTransferInProgress());    // Wait While Busy
          vAHI_SiMasterWriteData8(u8ReadAddress);          // Address to Start Read From
          bFlag = bAHI_SiMasterSetCmdReg(E_AHI_SI_NO_START_BIT,
                                                                      E_AHI_SI_NO_STOP_BIT,
                                                                      E_AHI_SI_NO_SLAVE_READ,
                                                                      E_AHI_SI_SLAVE_WRITE,
                                                                      E_AHI_SI_SEND_ACK,
                                                                      E_AHI_SI_NO_IRQ_ACK);
          while(bAHI_SiMasterPollTransferInProgress());    // Wait While Busy
          vAHI_SiMasterWriteSlaveAddr(BMP085_R>>1,TRUE); // TRUE - Read Operation
          vAHI_SiMasterSetCmdReg(E_AHI_SI_START_BIT,
                                                  E_AHI_SI_NO_STOP_BIT,
                                                  E_AHI_SI_NO_SLAVE_READ,
                                                  E_AHI_SI_SLAVE_WRITE,
                                                  E_AHI_SI_SEND_ACK,
                                                  E_AHI_SI_NO_IRQ_ACK);
          while(bAHI_SiMasterPollTransferInProgress()); // wait while busy
          // now we can start reading data back from the eeprom
          while(u8ReadLength > 0)
          {
                    if(u8ReadLength < 2)    // is it the last byte
                    {
                              vAHI_SiMasterSetCmdReg(E_AHI_SI_NO_START_BIT,
                                                                      E_AHI_SI_STOP_BIT,
                                                                      E_AHI_SI_SLAVE_READ,
                                                                      E_AHI_SI_NO_SLAVE_WRITE,
                                                                      E_AHI_SI_SEND_NACK,
                                                                      E_AHI_SI_NO_IRQ_ACK);
                    }
                    else
                    {
                              vAHI_SiMasterSetCmdReg(E_AHI_SI_NO_START_BIT,
                                                                      E_AHI_SI_NO_STOP_BIT,
                                                                      E_AHI_SI_SLAVE_READ,
                                                                      E_AHI_SI_NO_SLAVE_WRITE,
                                                                      E_AHI_SI_SEND_ACK,
                                                                      E_AHI_SI_NO_IRQ_ACK);
                    }
                    while(bAHI_SiMasterPollTransferInProgress()); // wait while busy
                    u8DataOut[i] = u8AHI_SiMasterReadData8();
                    i=i+1;
                    u8ReadLength--;
          }
}

PRIVATE void vI2CWrite (uint8* u8DataIn, uint8 u8Length)
{
          uint8 i = 0;
          uint8 u8WriteLength;
          u8WriteLength = u8Length;
          // set slave address
          vAHI_SiMasterWriteSlaveAddr(BMP085_W >> 1,FALSE);
          bAHI_SiMasterSetCmdReg(E_AHI_SI_START_BIT,
                                                  E_AHI_SI_NO_STOP_BIT,
                                                  E_AHI_SI_NO_SLAVE_READ,
                                                  E_AHI_SI_SLAVE_WRITE,
                                                  E_AHI_SI_SEND_ACK,
                                                  E_AHI_SI_NO_IRQ_ACK);
          while(bAHI_SiMasterPollTransferInProgress()); // wait while busy
          // now we can start writing data to the device
          while(u8WriteLength > 0)
          {
                    // data to write
                    vAHI_SiMasterWriteData8(u8DataIn[i++]);
                    if(u8WriteLength < 2)    // is it the last byte
                    {
                              bAHI_SiMasterSetCmdReg(E_AHI_SI_NO_START_BIT,
                                                                      E_AHI_SI_STOP_BIT,
                                                                      E_AHI_SI_NO_SLAVE_READ,
                                                                      E_AHI_SI_SLAVE_WRITE,
                                                                      E_AHI_SI_SEND_NACK,
                                                                      E_AHI_SI_NO_IRQ_ACK);
                    }
                    else
                    {
                              bAHI_SiMasterSetCmdReg(E_AHI_SI_NO_START_BIT,
                                                                      E_AHI_SI_NO_STOP_BIT,
                                                                      E_AHI_SI_NO_SLAVE_READ,
                                                                      E_AHI_SI_SLAVE_WRITE,
                                                                      E_AHI_SI_SEND_ACK,
                                                                      E_AHI_SI_NO_IRQ_ACK);
                    }
                    u8WriteLength--;
                    while(bAHI_SiMasterPollTransferInProgress()); // wait while busy
          }
}

I spent few days in understanding I2C protocol in general to start integration of pressure sensor with Jennic board, so I thought it would be beneficial to write in blog for others who found difficulty as well.

If anyone still interested in complete code, you can ask. I can send it you :)

Wednesday, June 29, 2011

Extracting specific data block, from text file, associated withcorresponding label and store data in structure variables of respectivedata type by using C/C++ environment

Requirements:
Text file, having structure similar to like this.
Label-1
$A,1234,B56F,5.678;:
Label-2
$B,7890,C00E,5.678;:
........
Analysis:
The case under consideration is as:
Label-1
$A,1234,B56F,5.678;:
'Label-1' relates to data block "$A,1234,B56F,5.678;" (separated by ','). In my case data block format consist of three parameters is pre-decided:
$A -> Header1234 -> Integer Value
B56F -> Hex Value
5.678 -> Float Value
; -> Footer
: -> represents the termination of data block
Upon retrieval of data block, the task is to extract and assign values to data structure parameters as per requirements.

Design & Development:
'tsDataBlock' is structure with four parameters as observed in analysis phase:

typedef struct stDataBlock
{
          int iParam1;
          int iParam2;
          float fParam3;
};
int _tmain(int argc, _TCHAR* argv[])
{
          stDataBlock sDataBlock;
          ifstream inFile;
          inFile.open("configFile.txt"); // Text File containing data
          char cLabel[10] = "Label-1"; // Label to search
          bool bFlag = false;
          char cDataBuffer[50];
          char cParam1[10];
          char cParam2[10];
          char cParam3[10];
          char *pch[5];
          int i = 0;
          inFile.getline(&cDataBuffer[0], 10); // Get line containing Label
          // Get corresponding data block
         {
                  // Check if Parameter 1 is integer as data type in data structure
                  // Finally print all values
                  printf("\nParam 1 %d", sDataBlock.iParam1);          
                  printf("\nParam 2 %x", sDataBlock.iParam2);
                  printf("\nParam 3 %f", sDataBlock.fParam3);
                  cin.ignore();
                  return 0;
         }
         
         while (!bFlag && (inFile.eof() != 1))
         {
                    if (strcmp(cDataBuffer, cLabel) == 0)
                    {
                              inFile.getline(&cDataBuffer[0], 50, ':');
                              cout<<"Corresponding Data Block: ";
                              // String tokenizer, excepts header, separator, and footer character
                              pch[0] = strtok(cDataBuffer, "$A,;");
                              while (pch[i] != NULL)
                              {
                                        i++;
                                        pch[i] = strtok(NULL, "$,;");
                              }
                              strcpy(cParam1, pch[0]); // Parameter 1
                              strcpy(cParam2, pch[1]); // Parameter 2
                              strcpy(cParam3, pch[2]); // Parameter 3
                              printf("Param 1: %s, Param 2: %s, Param 3: %s",
                                        cParam1, cParam2, cParam3);

                              if (i == 3)          
                              {
                                        // Check if Parameter 1 as integer data type
                                        if(!sscanf(cParam1,"%d", &sDataBlock.iParam1))
                                        bFlag = false;          
                                        // Check if Parameter 2 as hexadecimal data type
                                        if(!sscanf(cParam2,"%x", &sDataBlock.iParam2))
                                        bFlag = false;
                                        // Check if Parameter 3 is float as data type
                                        if(!sscanf(cParam3,"%f", &sDataBlock.fParam3))
                                        bFlag = false;
                              }
                              // Finally print all values
                              printf("\nParam 1 %d", sDataBlock.iParam1);
                              printf("\nParam 2 %x", sDataBlock.iParam2);
                              printf("\nParam 3 %f", sDataBlock.fParam3);
                    }
}
          cin.ignore();
          return 0;
}

Saturday, December 11, 2010

Failed to download repository information

GPG error 'NO PUBLIC KEY FOUND':

Still, I am not sure that how public keys were deleted, but these keys can be recovered by running the following command in terminal.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AF5ED91C56978EF9

Replace hexadecimal numbers with the number written in the error while updating ubuntu. If there are more than one error then run the above command by changing the hexadecimal numbers associated with each error. At the end run the following command,
sudo apt-get update

I hope it will work :)

Saturday, December 4, 2010

Base64 – Encode and Decode JAVA Functions

Find information on Wikipedia about Base64
privatestatic String toBase64Encode(Serializable o)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos;
try
{
oos = new ObjectOutputStream( baos );
oos.writeObject( o );
oos.close();
}
catch (IOException e)
e.printStackTrace();

returnnew String(Base64.encodeBytes(baos.toByteArray()));
}

privatestatic Object toBase64Decode(String s)
{
byte [] data = Base64.decode(s);
ObjectInputStream ois;
try
{
ois = new ObjectInputStream(new ByteArrayInputStream(data));
Object o = ois.readObject();
ois.close();
return o;
}
catch (IOException e)
e.printStackTrace();
catch (ClassNotFoundException e)
e.printStackTrace();

returnnull;
}

Thursday, November 18, 2010

Distributed Locking Manager (DLM)

Abstract

The race of high-speed communications and high quality service provisioning is compelling the market to move towards less expensive and far reaching ways to provide services to the stakeholders. Evolution of distributed computing in consistency with extremely large networks abstracting the underlying equipments and protocols, leads the way into the world of concurrent access of available resources, at frequencies far higher than ever. Concurrency control, at present day, is being molded into a solution module called “Distributed Locking Manager” or commonly “DLM”, which is aimed to manage the concurrent access of resources while preventing network chaos. This paper is aimed to provide the reader a thorough insight into the functionality and evolution of the Distributed Locking Manager, from educational and development point of views. We present the reader with a generalized overview about the operation of DLM module. Apart from the fact that at present, different solutions for implementation of DLM are available in the market, the insight presented applies to all, in general. The vendor specific solutions differ in terms of attribute provisioning, levels of granularity or establishing communication for resource access, however, the main principles and core logics are intact in each of them. We describe the evolution of DLM from past to the present and reach some conclusions at the end of this paper which are quite essential for the integration of DLMs into distributed networks allowing for heterogeneous hardware functionalities and convergence of technology into large footprints.

Saturday, June 19, 2010

Intelligently Present Info Screen (IPIS) [Human Computer Interaction]

Abstract

The IPIS (Intelligently Present Info Screen) application will guide a user to find important places, important persons, ongoing cultural events, moral stories and histories of a place and talent hunt events. Application will show user current location automatically in a map. It will indicate important places, persons, cultural activities and moral stories & histories in a map which are closest to user current position. Suppose users are in Duomo, Milan, Italy, application will suggest users “Roman Catholic” as a historical place showing in map to visit that place. Also in application user can tag places, important persons, cultural events and moral stories. General user or foreigner who want to search for a particular place or want to join in local cultural activities, application will help them. Application will show available transportation, shortest path and brief history of that place if available. Moral histories, user experience and comment will preserved by this application. This will be a digital preserve system where user can share each other experiences. User can broadcast their talent in a second. Application will help users to participate in a talent hunt event remotely .Suppose user current position is Milan and talent hunt event is ongoing in USA, Hollywood then user will perform in front of i-phone and that will be shown in a TV screen in talent hunt event in front of judge for judgment. Now if user want to move Milan to Rome and want to visit some tourist places on the way, application will guide them and draw road map according to tourist places. This application will be integrated with i-phone’s existing application.

Friday, June 18, 2010

Customized Function Module Integration in PerLa for WSNs

Abstract

PerLa or Pervasive System language is a declarative language for application in pervasive computing. This concept behind PerLa is to provide the user with the opportunity to manage heterogeneous pervasive devices while avoiding the complexity of underlying hardware. At present, PerLa provides the users with a declarative approach towards the network to be managed. However, a limitation which arose with increase of applicability of the language was the absence of any mechanism to induct customized user functions to perform need-based operations on the data e. g. filtering operations, performing statistical functions on the data and special-case procedural code inductions. In this report, we propose a way to introduce the possibility of integrating procedural functions in the existing declarative approach offered by PerLa. In order to allow for this approach, it is necessary to embed the custom-code in the system such that the existing architecture is disturbed at a minimum and maximum functionality is achieved. We present the solution in which the system capabilities can be extended with the design point of view. The implementation of these functionalities is separated from the design phase, covered in this report.

Saturday, June 5, 2010

SESC: Design Space Exploration of Architectural Simulators using MulticubeExplorer

During the last decade, researchers realized that increasing transistors to microprocessor in order to increase clock rate is not the solution to increase applications performance rather focusing on research optimize programming models and effective use of microprocessor will be the better solution. The increase in Power/Density ratio of microprocessors is leading towards the situation from where there will be no way to resolve heat dissipation.
One solution can be utilizing specialized hardware dedicated to accelerate specific applications of system which is known as heterogeneous processing; for example, GPUs for graphics applications, DSPs for complex mathematical applications, FPGAs for performance critical applications, Intel Microprocessors for general purpose computing. Although, accommodating specific hardware for specific application provides high performance with better power efficiency. In return heterogeneous systems become difficult to program, mostly because of taking care of managing data flow between different architectural processors from the execution point of view.
Other one is known as homogeneous processing consisting processors of the same architecture. In multi-processing, processors work together in tightly coupled manner in order to process one or more jobs simultaneously. All processors have strong connection to each other by sharing common clock, instruction set etc. By increasing processors never create any problem for the designer due to same architecture pattern. Multi-processors increased reliability of the system, if one of the processor goes down then load is transferred or shared between other processors. On the other hand, in heterogeneous systems it will be complete shutdown of the system.
In order to achieve optimum performance of the system, we need architecture which is capable of accommodating both heterogeneous and homogeneous processing units. Multiple processing usages are becoming essential part of the embedded systems development nowadays. While considering multi-core architectural pattern, each core can be dedicated to perform certain specific task. The important task is to plan and map work load on different cores need to be done before writing algorithms. This article is to explain one of the Multi-core Architecture Simulator (SESC) and Multicube Explorer which helps the designer in order to explore design space of multi-core architecture.

SESC Simulator:
Simulator or Architectural Simulator is basically a software model which actually replicates actual hardware/software resources of the actual system. The core purpose of simulator is to predict system behavior and performance metrics relevant to specific inputs. This Architectural Simulator can either model microprocessor or complete system consists of microprocessor, memory, and I/O devices.
SESC is one of the architectural simulators that can model different processor architectures, such as single processors, chip multi-processors and processors-in-memory. It models a full out-of-order pipeline with branch prediction, caches, buses, and every other component of a modern processor necessary for accurate simulation. SESC is an event-driven simulator. It has an emulator built from MINT, an old project that emulates a MIPS processor. Many functions in the core of the simulator are called every processor cycle. But many others are called only as needed, using events.

More information about SESC Simulator is available on http://sesc.sourceforge.net/. SESC project started at University of Illinois at Urbana‐Champaign.

Multicube Explorer:
Multicube explorer is an interactive program that lets the designer explore a design space of configurations for a parameterized architecture for which an executable model (use case simulator) exists. Multicube explorer is an advanced multi-objective optimization framework which is entirely command-line/script driven and can be re-targeted to any configurable platform by writing a suitable XML design space definition file and providing a configurable simulator. Multicube Explorer is supported by the EC under grant FP7-216693 MULTICUBE (http://www.multicube.eu).

The tool and the documentation can be currently found at the following address: http://home.dei.polimi.it/zaccaria/multicube_explorer.

Integration files required for design space exploration of SESC Simulator consist of:
  • Python Script: The script used for generating of input/output configuration file of the SESC Simulator.
  • XML Driver: Design space exploration file.
  • Multicube Script: The m3explorer script file which actually automated the exploration process.
  • Shell Script: The shell script which automates the whole integration process of SESC Simulator and Multicube Explorer.

Wednesday, February 25, 2009

Python integration with Bioloid (An Overview)

What is Python:
Python is scripting language as paradigm. The Python features are the combination of programming language like C, JAVA and Functional languages, which are;
- Imperative (procedural oriented like C)
- Object Oriented (like JAVA)
- Functional (like Haskel, LISP)

What is Bioloid:
Bioloid is a robotic kit made up of interchangeable block-shaped parts. By using these parts, we can build different types of robots performing various tasks. The name Bioloid comes from words “Bio” + “all” + “oid” meaning that any living thing can be built in the form of a robot.

Bioloid Hardware:
The hardware of the Bioloid consists of three types.
- CM-5: The main central processing unit and power source of Bioloid robotics system resides in CM-5 unit. The main purpose is to program execution and storage that interact with AX series Dynamixel (AX-12 Actuator and AX-S1 Sensor). Atmel’s Atmega128 microcontroller, containing four Dynamixel serial ports, programmable control buttons, and status LED's (including one auxiliary programmable led).
- Dynamixel: This is the basic unit of the Bioloid which acts as a joint or a sensor. The AX-12 Dynamixel is an actuator that is used as a joint. The AX-S1 Dynamixel is a sensor unit that can sense both distance and sound.
- Frame: The frame connects the robot units. The Dynamixels can be connected together with the use of the frame. Also, the frame connects the Dynamixels and the CM-5 unit.
More detailed information can be found in manuals of CM-5, AX-12, and AX-S1 Dynamixel.
Most of the research in robotics focuses not on specific industrial tasks, but on investigations into new types of robots, alternative ways to think about design robots, and new ways to manufacture them. A first particular new innovation in robot design is the open sourcing of robot-projects.

There is some group of developers who made interpreters for robots integration. Some are PyRo (www.purorobotics.org), PyMite (http://pymite.python-hosting.com/wiki/PyMite), Swig (www.swig.org), MyRo. By using these interpreters we can integrate robot with Python language to perform different operations.

Discussion on PyRo:
Still Bioloid hardware has some integration problems. Associate Professor Douglas Blank, one of the PyRo developers told me that there is no support for Bioloid in PyRo. His student, Teyvonia Thomas, is working on controlling the Bioloid's CM5 from Python, through an add-on board called the Fluke. Furthermore, he elaborates a new software project, called Myro, which is a simplified interface for robotics. Teyvonia is working on further documentation so that anyone can build a serial over Bluetooth interface with the Bioloid kit. Once you have a serial connection established, then you will need a method of programming the Bioloid motors. I suspect that Teyvonia will have an interface that allows setting gestures/poses, and also gives individual joint control as well. This is a combination of a firmware program on the CM-5, and a series of commands given over the serial line.
Once you have a serial interface, creating a PyRo object is very easy. However, there isn't any support in Pyro for articulated joints. This will be all new interfaces created by Teyvonia. (Although Player/Stage has recently created an act array, an array for controlling articulated arms.)

http://wiki.roboteducation.org/Designing%2C_Building_and_Programming_a_Hexapod:_From_King_Spider_to_TevBot#Electronic_Components
http://wiki.roboteducation.org/Exploring_Search_and_Rescue_with_TevBot

But the point is what is the serial communication protocol of Fluke board and CM-5 Unit?, and if some communication is established between Fluke and CM-5 using Python then it means that Python can be directly communicate with CM-5.

Fluke Hardware: The Fluke is a small electronic board that contains wireless Bluetooth, camera, IR (infrared) sensors, LEDs (light emitting diodes) and an ARM microprocessor. By itself (with a battery), it is a complete (although immobile) robot that can receive simple commands and send back IR readings, camera images, and turn on its LED lights. Connect it to a robot and you can control the robot wirelessly, and add vision and sensors to it. The more detail of the Fluke hardware and its integration is given the website http://wiki.roboteducation.org/Hacking_the_Fluke.

Discussion on PyMite:
I have another discussion with Dean Hall, working in Apple Macintosh and core-developer of PyMite. PyMite is a Python interpreter in order to execute on 8-bit and larger microcontrollers with resources as limited as 64 KB of program memory (flash) and 4 KB of RAM. A brief introduction of PyMite is given in the report. As Bioloid contains AVR microcontroller having total 4KB RAM and PyMite itself require 4KB RAM, so it will quite hard to run Bioloid on PyMite interpreter. I am quoting his rough outline of what I would need to do:
“1. Learn how to build PyMite for ATmega128 (you'll have to learn how Makefile works and edit the arguments to avr-gcc to tell it that you want the ATmega128 processor)
2. Adapt the general AVR platform to your ATmega128 (clocks, interrupts, heap size all have to be tuned to your platform).
3. Learn how to make PyMite native functions (C code wrapped by Python function) so you can call functions to control the Bioloid.
4. Learn PyMite internals so you can remove functions/libraries you don't need in order to have enough RAM to run your program. And I've already made PyMite as small as possible, so there isn't much you will be able to do with only 4 KB of RAM.
I am going to say this again for emphasis #4 is almost a show-stopper. The ATmega128's 4KB of RAM will not leave you with much room to run a program (toggle some pins, ramp a PWM maybe; but nothing elaborates).”

Bioloid Hardware Limitations:
Bioloid hardware is still in the research phase to explore the way to make its connection with Python language. PyRo a Python interpreter still have no support for Bioloid hardware. PyRo, supports some robots like Pioneer, Aibo, Khepera, Soccer Robots, having server client based architecture. From PyRo Robotics website, I did not find any clue to connect AVR microcontrollers through Python. An email conversation with Associate Professor Douglas Blank, core developer of PyRo, elaborates that there is software named as MyRo, and Fluke board, by using both CM-5 unit integration is possible.
PyMite is another python interpreter which provide interface between AVR controllers and Python. PyMite interpreter required 4KB of SRAM at the time of execution and deployment of program code, but on the other hand ATmega128 controller has total 4 KB SRAM which is also impracticable solution.

Related Articles:
Install Python on Linux and how to try Python? (hackerz4u.com)
Ruby, Python, and Science (johndcook.com)

Wednesday, January 28, 2009

MapReduce: An exclusive Software Framework for Distributed Systems byGoogle

MapReduce is a software framework introduced by Google to support distributed computing on large data sets on clusters of computers. The framework is inspired by map and reduce functions commonly used in functional programming, although their purpose in the MapReduce framework is not the same as their original forms. MapReduce libraries have been written in C++, Java, Python and other programming languages.


MapReduce Motivation:

To motivate MapReduce, we will talk about the Functional Programming that MapReduce encompasses in its distributed settings. So, MapReduce drew its inspiration from functional languages like LISP, Haskell, ML; and there are many features of these programming languages which are common across among but with different syntaxes. So, firstly we will discuss about functions of LISP that become basis for MapReduce. There are few things that we have to remember while dealing with functional programming and how they are different from imperative languages such as C, JAVA etc.


Functional Programming Basics:

So, the very basic thing to remember is that Functional Programming operations don’t modify data structures. They always create new ones. They copy the data to represent in updated form, which means that original data will remain in its unmodified form, so, if we have different we have multiple components of program which are operated on same data, they don’t need to synchronize when one of these tasks has updated the data. Because updated data reflected as a new copy, which means that data flow is implicit in the program design. Every time when we have a new data, we have to assign a new name to it.
In more concrete examples, we have functions over list of integers, and this functions returns a value might be sum of every integer to itself, either multiplication or length of list as shown in below,

fun foo(l: int list) =
sum(l) + mul(l) + length(l)

The order of sum(), mul(), and length() doesn’t matter because they don’t modify list. What is the key of these function??? And that is, none of these functions has side effects, being referred to as pure functions. Where side effects referred to things such as printing to screen, user interaction, or writing data to disk connected to network. Pure functions simply expresses mathematical computations such as we see in Algebra. So, knowing that sum(), mul(), and length() are pure functions, we can evaluate them either form left to right or right to left, or if we are so clever then we can put these functions into separate threads and get the results by simply join them together at the end of computation. On the other hand, there are some other functions that can actually modify the list, such as append() as shown,

fun append(x, list) =
let list’ = reverse list in
reverse(x :: list’)

The element x is going to append at list and list will be modified. But as we see in the above code, the list is renamed after second line with new word list’ is introduced for the computation. So, by creating new name for data we made data flow explicit in the program.

The functions themselves can be used as an arguments to other functions that is directly applied by MapReduce.

fun DoDouble(f, x) = f(f, x)
(it doesn’t matter that what ‘f’ will do to ‘x’, DoDouble will do it twice. E.g. fn => fn z => z * 2)

Data type of DoDouble() depends upon the argument if it is integer the return type of function will be integer, or double, float etc. If it is string, using for some concatenation purposes, then return type will be string. That is he basics for the functional programming. Functional programming is also associated with its standard libraries, the names of these functions may vary from language to language. Functional programming in particular is operated on lists, so most of the functions have to deal with it, and two of the most commonly used functions are Map and Fold.


What Map does???

Map applied on the ‘list’ operated by function ‘f’ and returns an independent list, ‘f’ values extracted from the list and data type of the above list is different from the list obtained by applying function. For example, if Map function is applied on any document, then it may return all integers which appear in the document or may be words or characters, vary from situation to situation.


Google motivation towards MapReduce:

So, the motivation for designing MapReduce was that GOOGLE has large problems in joint datasets, sometimes larger than peta-byte of data as input and then process run on several thousands of processors to accomplish task up to some reasonable time. Google want to make this whole process easier for the programmers to do their work. So, MapReduce was developed as framework provide automatic parallelization & distribution. So, programmers use these functions to save their time.


Programming Model of MapReduce:

MapReduce consist of two functions map() and reduce() borrows from functional programming, detail of these functions is given below:

map(in_key, in_value) => (out_key, intermediate_values) list

"Map" step: The master node takes the input, chops it up into smaller sub-problems, and distributes those to worker nodes. (A worker node may do this again in turn, leading to a multi-level tree structure.) The worker node processes that smaller problem, and passes the answer back to its master node.


reduce(out_key, intermediate_values: list) => out_value_list

"Reduce" step: The master node then takes the answers to all the sub-problems and combines them in a way to get the output - the answer to the problem it was originally trying to solve.


The advantage of MapReduce is that it allows for distributed processing of the map and reduction operations. Provided each mapping operation is independent of the other, all maps can be performed in parallel - though in practice it is limited by the data source and/or the number of CPUs near that data. Similarly, a set of 'reducers' can perform the reduction phase - all that is required is that all outputs of the map operation which share the same key are presented to the same reducer, at the same time. While this process can often appear inefficient compared to algorithms that are more sequential, MapReduce can be applied to significantly larger datasets than that which "commodity" servers can handle - a large server farm can use MapReduce to sort a petabyte of data in only a few hours. The parallelism also offers some possibility of recovering from partial failure of servers or storage during the operation: if one mapper or reducer fails, the work can be rescheduled -assuming the input data is still available.


Logical view:

The Map and Reduce functions of MapReduce are both defined with respect to data structured in (key, value) pairs. Map takes one pair of data with a type on a data domain, and returns a list of pairs in a different domain:

Map(k1,v1) -> list(k2,v2)

The map function is applied in parallel to every item in the input dataset. This produces a list of (k2,v2) pairs for each call. After that, the MapReduce framework collects all pairs with the same key from all lists and groups them together, thus creating one group for each one of the different generated keys.

The Reduce function is then applied in parallel to each group, which in turn produces a collection of values in the same domain:

Reduce(k2, list (v2)) -> list(v2)

Each Reduce call typically produces either one value v2 or an empty return, though one call is allowed to return more than one value. The returns of all calls are collected as the desired result list.

Thus the MapReduce framework transforms a list of (key, value) pairs into a list of values. This behavior is different from the functional programming map and reduce combination, which accepts a list of arbitrary values and returns one single value that combines all the values returned by map.
It is necessary but not sufficient to have implementations of the map and reduce abstractions in order to implement MapReduce. Furthermore effective implementations of MapReduce require a distributed file system to connect the processes performing the Map and Reduce phases.


Example:

The canonical example application of MapReduce is a process to count the appearances of each different word in a set of documents:

map(String name, String document):

// key: document name
// value: document contents
for each word w in document:
EmitIntermediate(w, 1);

reduce(String word, Iterator partialCounts):
// key: a word
// values: a list of aggregated partial counts
int result = 0;
for each v in partialCounts:
result += ParseInt(v);
Emit(result);

Here, each document is split in words, and each word is counted initially with a "1" value by the Map function, using the word as the result key. The framework puts together all the pairs with the same key and feeds them to the same call to Reduce, thus this function just needs to sum all of its input values to find the total appearances of that word.



Execution Process:

We can see all this graphically from Figure, we have set of mapper(workstation nodes) that are connected to some data source(could be files, data tables). And each map process creates set of intermediate values tagged by certain intermediate keys and values. The barrier is the synchronization mechanism, which just waits for all the process to complete so when we have ‘n’ processes then there is counter on master machine, starting form ‘n’ and decrements to ‘0’. By hitting ‘0’, it will block all the tasks(threads) at once. At this time, we agreed that intermediate values are all together. All same values shuffle by reducers and go to particular reducer ‘1’ or ‘2’ etc. So, parallelism created by MapReduce comes with this fact that there is no synchronization among each mapper and the running threads are totally independent to each other, similarly for the reducers.
Each work node has its own buffering memory to store intermediate keys and values. So if one of the node goes down then mapper(Master) rescheduled its assigned tasks to any other free node. But if unfortunately master or database goes down, then whole process will be aborted to some specific time.


Optimization during Execution Process:

No reduce function will start until all map functions perform their tasks, in the mean while there may be one system that is too slow then the other nodes, which can limit the overall process. In this situation too, the master node is taking care of this, by scheduling the slower node tasks to other nodes which are free.
In the same time, another function named as combiner(), taking care of gathering all same intermediate values produced by mappers. So, combiner() causes mini reducer phase to occur in order to save bandwidth.


Fault Tolerance:

MapReduce also provide Fault Tolerance by managing tasks to any other free node(machine) if one of the node gets fail due to any problem either network failure or system crash down. Because if there are thousands of computers interconnected for performing some job and one of the computer goes down, it will defiantly stop the whole process.


MapReduce: A Major Step Backward: (From Database Community…)

A giant step backward in the programming paradigm for large-scale data intensive applications
A sub-optimal implementation, in that it uses brute force instead of indexing
Not novel at all -- it represents a specific implementation of well known techniques developed nearly 25 years ago
Missing most of the features that are routinely included in current DBMS
Incompatible with all of the tools DBMS users have come to depend on


My point of View:

Unfortunately, I don't work more in the field of databases, but one thing is sure that every person always try to adopt the procedure which is easy to learn and have less complications. Handling data using SQL requires more knowledge than using MapReduce function, because syntax of map() & reduce() is C or JAVA, and everyone is familiar with this. MapReduce technique can be applied to either structured or unstructured data but SQL always require structured from of data for further analysis or computations. So, I think, MapReduce has proven to be a useful abstraction for simplifying large computation on distributed computing.


References:


Integration of SQLite3 and Netbeans C/C++ IDE

Few days back, I wanted to use SQLite database for one of my project. I spend couple of hours to find a way to integrate with Netbeans. Mayb...