Wednesday, July 22, 2009

Exploring Intel processors for SIMD support

As we already know that there are various way to speed up the processes or applications by parallel operations like Single Instruction Multiple Data(SIMD), multithreading, pipelining, cache management etc. Here I tried to manage a list of specifying which Intel SIMD capability we can use as per processor specific. Although you can check this by using CPU-Z or playing with cpu_detect() function to read cpu-id.

MMX: Truly saying as in 2009, all current processors support MMX. It has 8 registers MM0-MM7 of 64 bit width. Just to maintain uniformity of blog, MMX support came with Intel® Pentium-MMX and from Pentium2 onwards every processors support it.

SSE: It was another big move in SIMD by having another 128 bit registers by Intel. It is good choice for Intel® Pentium3 and Intel® Pentium3m version.

SSE2:
Intel® Xeon®
Intel® Pentium4 (Willamette),
Intel® Pentium4m,
Intel® Pentium M,
Intel NetBurst-based CPUs (Pentium 4, Xeon, Celeron, Celeron D, Celeron M)
Intel Core-based CPUs (Core Duo, Core Solo)
Intel Core 2-based CPUs (Core 2 Duo, Core 2 Quad)
Intel Atom


SSE3:
Dual-Core Intel® Xeon® 70XX, 71XX, 50XX Series
Dual-Core Intel® Xeon® processor (ULV and LV) 1.66, 2.0, 2.16
Dual-Core Intel® Xeon® 2.8
Intel® Xeon® processors with SSE3 instruction set support
Intel® Core™ Duo
Intel® Core™ Solo
Intel® Pentium® dual-core processor T21XX, T20XX series
Intel® Pentium® processor Extreme Edition (but NOT Pentium 4 Extreme Edition)
Intel® Pentium® D
Intel® Pentium® 4 processors with SSE3 instruction set support (Since Prescott Versions)
Celeron 420, 430 and 440 and Celeron D
Intel Core 2 Quad edition
Atom


SSSE3:
Quad-Core Intel® Xeon® 73XX, 53XX, 32XX series
Dual-Core Intel® Xeon® 72XX, 53XX, 51XX, 30XX series
In tel® Core™ 2 Extreme 7XXX, 6XXX series
Intel® Core™ 2 Quad 6XXX series
Intel® Core™ 2 Duo 7XXX (except E7200), 6XXX, 5XXX, 4XXX series
Intel® Core™ 2 Solo 2XXX series
Intel® Pentium® dual-core processor E2XXX, T23XX series
Celeron 4xx Sequence Conroe-L
Celeron Dual Core E1200
Celeron M 500 series
Atom

SSE4.1:
Intel® Xeon® 74XX series
Quad-Core Intel® Xeon 54XX, 33XX series
Dual-Core Intel® Xeon 52XX, 31XX series
Intel® Core™ 2 Extreme 9XXX series
Intel® Core™ 2 Quad 9XXX series
Intel® Core™ 2 Duo 8XXX series
Intel® Core™ 2 Duo E7200 (Penryn )

SSE4.2:
Intel® Core™ i7 Processors (Nehalem)
Intel® Xeon® 55XX series

Now play with SIMD with different processors options available.

Tuesday, July 07, 2009

Banning Religious Names in Unholy things

One must say India is changing a lot nowadays.
Few days before the law Commission suggested repeal of Section 377 is not only major step taken recently, now the Goa government has banned all the liquor bars those are having any religious names.So those days are gone in Goa when after full day enjoyment in beaches, you think to hang out at Laxmi bar or St Anthony bar.


As per the news No cheer in God's name, Goa tells bar owners finance department has said: "No licensee having a licence for retail sale of India-made foreign liquor and country liquor and/or foreign liquor for consumption on premises shall carry out the business in the name and style which denotes any religious name." Even as per news opposition leader Manohar Parrikar said "God's name should be associated with good things. A bar is not a positive thing. Giving it god's name can hurt the sentiments of people. I don't think it is allowed anywhere in the country. The chances of unholy things happening in bars with holy names are high."

A big applause for Goa for doing this kinda work. I think this rule should apply to all over India not only Goa. If something is good and everybody accepting that, then why not apply everywhere.

Actually this news reminded me, one of my childhood memory. I guess many of adults who are almost of my age or more than me remember the "Laxmi Bomb". Remember at the time of "Diwali" we use this firecracker alot, Yea that one only.


Even I must say, "Laxmi" was very guaranteed crackers, very reliable, rare chance of spoiled one. Out of 10 boxes of crackers i used to buy 5 boxes of Laxmi (thinking 50% of sure success ;))



Around 2-3 years back I came to know that Government has banned that. Even I used to bring "Ganesh Bomb" also, that was also not available. Government banned all the crackers that has god or goddess name on it. The reason was I guess; the crackers had paper wrapped on it with name and image of god or goddess, so I should not describe what happened after explosion, I can only say it was really not religious things. I was very happy to hear that but at the same time my childhood mind was very disappointed after listening that news "What no Laxmi, no Ganesh........then what to buy, I dont have any faith on other bombs." ;)

Thursday, July 02, 2009

How to make DLL and DLL Application in Visual Studio

Dynamic Linking Library (DLL) has the following advantages:

1) Saves memory and reduces swapping. Many processes can use a single DLL simultaneously, sharing a single copy of the DLL in memory. In contrast, Windows must load a copy of the library code into memory for each application that is built with a static link library.

2) Saves disk space. Many applications can share a single copy of the DLL on disk. In contrast, each application built with a static link library has the library code linked into its executable image as a separate copy.

3) Upgrades to the DLL are easier. When the functions in a DLL change, the applications that use them do not need to be recompiled or relinked as long as the function arguments and return values do not change. In contrast, statically linked object code requires that the application be relinked when the functions change.

4) Provides after-market support. For example, a display driver DLL can be modified to support a display that was not available when the application was shipped.

5) Supports multi-language programs. Programs written in different programming languages can call the same DLL function as long as the programs follow the function's calling convention. The programs and the DLL function must be compatible in the following ways: the order in which the function expects its arguments to be pushed onto the stack, whether the function or the application is responsible for cleaning up the stack, and whether any arguments are passed in registers.

6)Eases the creation of international versions. By placing resources in a DLL, it is much easier to create international versions of an application. You can place the strings for each language version of your application in a separate resource DLL and have the different language versions load the appropriate resources.

A potential disadvantage to using DLLs is that the application is not self-contained; it depends on the existence of a separate DLL module.


With the use of dll's one application can use or perform multiple functionality by using multiple dll's. And another advantage is you dont have to give full code, just give applicxation .exe along with Library .dll and that 's enough to run the code.

To make an application by using dll, we need two different projects. One project will be Libarary for which we will make .dll and another will be appplication i.e. .exe file.

Ok let's start with Library project. Followings will be the steps:

1) Open visual studio and go to New Project. Choose "Win32 console project"
2) In application setting, choose DLL.


3) You will get 3 files in your project.
a) Dll_main.cpp b) stdafx.cpp and c) stdafx.h
you will also get some code already avaiable to those files. Just Keep it, those are required for compiler as an entry point to .dll



4) Now write your code or functions as usual only without main(). As main() will be in application project. Only thing is that the functions which will be avaialbe to applications, should to be exported. To export the function , you have to add "__declspec(dllexport)" before return type of function. I use define something like this

#define DLL_EXPORT __declspec(dllexport)

and header file will be


5) Other functions will be normal. no extra prefix. Just like I am using 'InsideHello()'in my DLL main.


6) Now go to project porpoety page, and to C/C++ section , and set "Not Using Precompiled Headers"



7) Now build the project, after successful build you will get ProjectName.lib and ProjectName.dll, so as for my case DLL_Lib.lib and DLL_Lib.dll. So you got your required .dll and .lib which we need for building application.

Now open new project for application. All settings will be normal as we do for usual .exe application.


and exported function of DLL_lib should be imported here by adding "__declspec(dllimport) " before return type of those function.


And now you have to add dependencies, for that go to property page and linker section and add as "input" the .llib file, for my case DLL_Lib.lib (which contain declarion of functions.)


And copy the .lib and .dll from the Library project in the folder where .sln is present of application project. That's it, now build the project, if build successful i.e. your application has taken .lib and .dll and can be used. So now for test, keep .exe application and .dll of lib anywhere, it will run properly.

Now if you want handle totally different functionality, by only one application, make diffrerent .dll's and use there functions in your application. just like i was testing, two .dll in one exe.both written separately, but later thought to use in one application.

Enjoy .dll applications now!!!!