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.

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...