Sunday, January 22, 2012

Haskell learning ( GHCI dump ) - Part #1

Prelude> let double x = x * x
Prelude> double 10
100
Prelude> double double 10

:1:1:
    No instance for (Num (a0 -> a0))
      arising from a use of `double'
    Possible fix: add an instance declaration for (Num (a0 -> a0))
    In the expression: double double 10
    In an equation for `it': it = double double 10

Prelude> double( double 10)
10000
Prelude> let factorial x = if ( x == 0 ) then 1 else x*factorial(x-1)
Prelude> factorial 100
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
Prelude>

Friday, January 20, 2012

How much Functional Programming a "bread and butter" programmer should know ?

Immutability - Pure functions - Referential Transparency -


Closure - Capture of Variables - First class functions -

Composition of Functions - Higher order functions - Functors -

Partial application and Currying - Importance of lazy evaluation -

Functions as values - Code as data - Data as Code -

Type inference - Lexical scoping vs Dynamic scoping -

Map/Filter/Fold - - Pattern matching - Monads -

Combinators - Types of Combinators - Anonymous recursion -

-Tail call elimination in recursion - Name free notation -

Controlled side effects - Software Transactional memory -

Concurrent programming - Purely Functional data structuers -

Mathematical induction vs Structural Induction - Continuation

Passing style - Functional Parsers - Parser Combinators -

Hygenic macros and modules - Meta Programming - Programming language semantics -

DSLs using Functional Programming - Mixing Functional Programming

and Object Oriented Programming - Emulating Functional Programming

idioms using C/C++,Java,JavaScript and C#





Tuesday, January 17, 2012

Simple Stupid Cuda Tutorial - Part 1

CUDA toolkit is used to write parallel programs using NVIDIA's GPU. Modern GPUs are not only for graphics,they are used for compute purpose as well. OpenCL is a standard for CPU/GPU co-processing and Microsoft has got their own DirectCompute for the same purpose

Following program assumes that you have installed NVIDIA's CUDA toolkit and it just uses a GPU to do a trivial task,one that of adding numbers. This program can be used as a starting point into writing Cuda programs.


//////////////////////////////


// CudaAdd.cu

//

// A Cuda Program to Add two numbers.... 

// The aim of this program is just to show

// how to use NVIDIA Cuda toolkit

//

//

// Written By

//

// Praseed Pai K.T.

//

// http://praseedp.blogspot.com

//

//

// if you have installed CUDA toolkit,executes

// at the Visual Studio Command Prompt...

//

// nvcc -o test.exe CudaAdd.cu

// test.exe

//





#include <stdio.h>



/////////////////////////////////////

//

// The following simple routine executes

// on a GPU 

//

//

//



__global__ void AddKernel(int a , int b, int *result )

{

*result = a + b;

}



/////////////////////////////////////

//

// main - CPU entry point ....

//

//



int main( int argc, char **argv )

{

int result; // to store CPU int...



int *dev_result; // to store the GPU int...



// --------- Allocate memory for the device result...

// --------- Let us assume that function won't fail...



cudaMalloc( (void**)&dev_result,sizeof(int));



//----------- invoke the Kernel Function...

//----------- __global__ gives a hint to nvcc that 

//----------- the stuff has to be compiled by GPU compiler



AddKernel<<<1,1>>>( 2, 7, dev_result ); 



//----------- Copy the dev_result from GPU memory to 

//----------- CPU memory 



cudaMemcpy( &result,

dev_result,

sizeof(int),

cudaMemcpyDeviceToHost ); 







printf( "%d + %d = %d\n",2,7,result );





cudaFree( dev_result );



return 0;





}

 

Here is the dump of my visual studio command prompt.....





I:\GRAPHICS_RES\CUDA_LEARN\FirstCuda>nvcc -o test.exe CudaAdd.cu

CudaAdd.cu

tmpxft_000009a0_00000000-3_CudaAdd.cudafe1.gpu

tmpxft_000009a0_00000000-8_CudaAdd.cudafe2.gpu

CudaAdd.cu

tmpxft_000009a0_00000000-3_CudaAdd.cudafe1.cpp

tmpxft_000009a0_00000000-14_CudaAdd.ii



I:\GRAPHICS_RES\CUDA_LEARN\FirstCuda>test

2 + 7 = 9



I:\GRAPHICS_RES\CUDA_LEARN\FirstCuda>

 

Monday, January 09, 2012

It seems Bangalore do not have a single happy soul (or I could not reach them)

Yesterday,I landed in Bangalore to finish some personal chorus and the moment I landed at the Silk board,as usual,auto-wallahs began to cluster around me and others. I began to walk towards the bus stop to board a bus to Banasankari.

While waiting at the bus stop , I began to observe things around me. I saw pale faces,stubborn faces,disinterested faces , faces immersed in thought removed from surroundings and this intrigued me. I began to search for a happy face all the day and I could not find one till five in the evening.

It seems Bangalore has got three class of people

A) People who wants to make it big
B) People who want to retain what they have made ( current biggies )
C) An army of clueless people wandering around

I might be wrong here as sample space is small. But,I suspect there is some element of truth






Saturday, January 07, 2012

Various projects as test automation architect at Intel Bangalore


At Intel,I worked as a test automation architect (staff augmentation resource from UST global) when some projects required high degree of involvement. I worked with PCCG group , VPG , Mobile application group and Intel Malaysia.



Some of the activities undertaken include



1) Enhancement of Bios Testing Framework
2) Auto IT scripting,C/C++ scripts for Test automation
3) Setting up of VPG (Graphics driver testing ) automation group
4) Pilot testing of Anvil,a declarative test authoring tool
5) Product definition for POS machine using Windriver
6) Hiring of the first level of Near field communication test automation staff for Meego & Android
7) Trailing developers in P/Invoke,COM-Interop


Tools and Technologies :- Anvil , Visual C++ , Auto IT,Perl , Python , Visual C#

Enterprise application for a retail chain(Groovy/Grails/AdobeFlex)


A software for retail chain dealing with medical instruments and pharmaceutical products is being developed at Ikya technologies,Trichur Kerala. The software has modules like Financial accounting, Inventory/Stores,Point of Sales,Purchase.

Being a concern distributed in different locations, they want data synchronization with in an hour,with their central server.





Role:- As a consultant , I am involved in the technologyselection,architecture and code quality. Defined the Data Synchronization strategy,Selected Oracle for the Central server and MySQL for the local server,Adobe Flex for rich client

application and Groovy and Grails for the server development. Wrote a tool to generate Action Script class files from Grails domain model and also wrote a service facade layer for one point of contact on the server.



Team size : 15



Technologies :- Groovy and Grails , Hibernate , Adobe Flex , BlazeDS , MYSQL , Oracle

RTTDeltaGen Low Poly modelling module


RTT ( Real Time Technologies,Munich ) is the world's leading physically based photo realistic rendering company. With a suite of products under the umberla of their flagship product,RTT DeltaGen , the company has got massive footprint in the high end visualization industry. (more details can be gleaned from http://rtt.ag )

Their client Addidas required an automatic low-polygon converter from Rhino 3D generated T-splines model. The models are imported into DeltaGen using an enhanced RTT's directrhino plugin. Once the data is inside the software, an OpenNurbs based software module will process it and RTT's tesselator will be used to tesselate the polygonated Nurbs modeller into meshes of different granularity. The textures are baked into the low-poly models using Normal maps. Once the low poly models and normal maps are generated , the resulting resources are saved into Autodesk FBX file format to be viewed from Autodesk Maya (for correctness ) and Unity 3D ( for Point of Sale ).

Role :- Studied Autodesk FBX SDK 2012 , re-wrote parts of RTT's FBX writer to incorporate texture channels (for normal map , ambient occlusion map , transparency map etc). Wrote the bulk of technical spec for the Low Poly module. Wrote some DirectX 11 based minimal viewer for the records which we were spitting into the FBX module .



Tools :- Visual C/C++ , DirectX SDK , Autodesk FBX SDK , RTT DeltaGen SDK, MFC



Team Size :- 4

Friday, January 06, 2012

A nice story told by a friend - I suspect , some morals and fun are embedded in it

An erstwhile colleague and friend narrated a story while we were having a telephonic conversation yesterday.

Here is the summary of story....

A "sanyasi" was travelling through a village street. While waiting under a tree , he noticed a lone struggling ant trying to get into it's dwelling. The sanyasi feared that ant will loose his life , if he has not managed to get into it's dwelling. To save the ant, he took the ant on his elongated beard and tried to ease his passage into the ant hive. The ant slowly went into the pack and sanyasi had a bunch of ants in his beard in return.

In the end , the sanyasi has to kill all of them to get out of the mess !!!.



Tuesday, January 03, 2012

Purchased NVIDIA GTX 550

I was using NVIDIA GeForce 9400 in my home PC. Being an earlier generation card ( shader model 4 / DirectX 10/ OpenGL 3.x ) , the driver only supports OpenGL 3.2 and DirectX 10 ( DirectX 11 support was there through Software Rasterizer from Microsoft ). I did some DirectX 11 programming while I was in Munich and It had re-kindled my interest in Shader model 5.

Today,I purchased a card which supports DirectX 11 and OpenGL 4.x in hardware. I have already got the book OpenGL shading language cookbook . I will program this card for some new Graphics "Gyan".