tag:blogger.com,1999:blog-75996406394910142582024-03-16T12:38:21.333+05:30TechnologyHere I writes about the technologies that I have used. C++,C#,HPC and many things.Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-7599640639491014258.post-83638610911012823612008-05-14T16:07:00.005+05:302008-05-14T17:53:25.064+05:30Why not Embedded C++?How embedded C++ differ from ISO C++? Embedded C++(EC++) language is a subset of ISO C++ and a program written in EC++ can be compiled with any ISO C++ compiler. EC++ is formed by omitting following features of ISO C++. 1. Multiple Inheritance 2. Virtual base classes 3. Run Time Type Information 4. New style casts 5. The mutable type qualifier 6.Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com3tag:blogger.com,1999:blog-7599640639491014258.post-26144078615247052842008-04-23T17:21:00.005+05:302008-04-23T17:38:08.853+05:30Virtual destructors (What? When? Why?)There are some questions regarding virtual destructor that I am asked very frequently. Answers to all these questions are similar so I am making a common note on it. • What is the use of virtual destructor? • When to make base class destructor virtual? • Is there any overhead for virtual destructor? • Why don’t we make all the destructor virtual? • Will the delete Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com3tag:blogger.com,1999:blog-7599640639491014258.post-66587917143145989092008-04-11T11:51:00.004+05:302008-04-11T12:07:17.074+05:30The development of NULL - A historyIntroduction Null pointer is a stuff which have had changes and advancement through out the development of C and C++. All the implementation had its own draw backs and now a perfect design is about to arrive in C++0x. Let us analyze the NULL pointer in C, C++ and C++0x.K&R style(C Style) A NULL pointer is a constant expression which evaluates to either 0 or ((void*) 0). There are Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-70252597941312039642008-02-21T14:43:00.000+05:302008-02-21T14:53:35.973+05:30A volatile reference and const referenceA volatile referencevoid foo(volatile double& bar ){ cout << bar << endl;}Above function accepts a reference to double. What happens if you call,int nVal = 0;Foo( nVal );An error will be generated by the compiler specifying the conversion from ‘ int ’ to ‘ volatile double & ’ is not possible.Why it shouldn’t cast? A casting has to be don when an integer need to be passed to a method Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-27387187429003041292008-02-12T14:27:00.000+05:302008-02-12T14:30:13.996+05:30Compromising quality for performanceIt has always been a big deal to compromise accuracy for performance. In most of the cases highly complex and time taking application will need highest accuracy. The accuracy has always been the problem in using GPU for performance improvement of such algorithms. Since the GPUs don’t support double precession arithmetic it looks hard to achieve high precision with it. CPU does floating point Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-76065671512256010962008-02-11T10:30:00.000+05:302008-02-11T10:38:56.347+05:30Did Herb Sutter fight with the Amdahl’s law?Understanding Amdahl’s law No matter how much speedup you get for the parallel code, it is impossible to make a speedup of 2x if 75% of the algorithm cannot be parallelized. Suppose if you do the other 25% with 0 seconds that makes you gain up to 1.3x. For quantifying, if your algorithm takes 1 second and if 0.75 second of it is non-improvable, it doesn’t matter how much improvement you Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com8tag:blogger.com,1999:blog-7599640639491014258.post-81317537519772422882008-01-18T16:18:00.005+05:302008-02-21T10:40:37.038+05:30Limiting the possible data types given for a template class during instantiationHow to limit the data types that can be used for instantiating a template class? In C++ there is no standard mechanism to limit the data types that a template can be created with. For example,template < class T>class ATemplate{}; The above class (ATemplate) can be instantiated with any data type. So ‘T’ can be any data type (eg. basic data types, structures and classes). But what if Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com37tag:blogger.com,1999:blog-7599640639491014258.post-27454164471186436202008-01-14T11:11:00.000+05:302008-01-14T11:28:36.082+05:30Teraflop processors is not far, Are we ready to use it?“The prototype 80-core Polaris processor on a single chip delivered the super computer like performance of a trillion floating-point operations per second (one teraflop) while consuming less than 62 watts – Intel.” It will take less than 10 years from now for a common man to have PC running on a teraflop processor. A prototype of teraflop processor has 80 cores which can be executed in Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-48974654597180570692007-12-10T21:19:00.000+05:302007-12-10T21:23:38.886+05:30What if someone come with a compiler capable of parallelizing the algorithms?In many training sessions I have heard a common question from most of the business men. If I give training to all my employees on parallel computing can you guarantee me that no one will come up with an automatically parallelizing compiler tomorrow? Won't all the money I spent on the training get wasted? Is it a big deal? This has been a very serious question for all these time. May be most Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-82412483325002480502007-12-05T11:37:00.000+05:302007-12-05T11:46:05.822+05:30Think parallel, save your productI always wonder why we all speak about performance. We uses many jargons like performance, optimization, throughput, scalability, parallel thinking, hybrid computing, threads, locks, semaphores, synchronization, penalty, data parallelism, instruction parallelism and many more. Why we are aiming on performance? What happened to the software industry in a very short span? Instead of just making Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-3782497993542899232007-12-05T11:05:00.000+05:302007-12-05T11:16:38.317+05:30Parallel Extension to .NET FrameworkSomething to hope for .NET programmers!!! Microsoft has come with a parallel extension to .NET framework (managed code). This may be a revolution in making high performance programs using .NET. But I wonder how many HPC applications can be done using .NET because of its lack of speed compared to a C/C++ program. I have written another article about the performance difference betweenAmal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com1tag:blogger.com,1999:blog-7599640639491014258.post-57198408066022848952007-12-03T12:28:00.000+05:302007-12-03T14:24:57.699+05:30High performance computingWhy? As human being greedy we will never settle down with what we have got. We will always look for more. That is exactly happening in high performance computing industry. Long back we had very slow processors which took seconds to sort a small chunk of data. Now we want to predict the climate of each and every location of world within seconds. There are lots of medical imaging algorithms Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-3627599930972244462007-12-01T15:50:00.000+05:302007-12-01T15:54:51.866+05:30CUDA - Compute Unified Device ArchitectureCompute Unified Device Architecture is an easy way to use GPU for General Purpose Programming. No graphics knowledge is required to use CUDA for doing a program using GPU. A CUDA program is almost same as a C program but have some additional features. In CUDA a function can be run in many threads by giving a execution configuration while calling a function. There are 3 kinds of functions in CUDA.Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-25115908109359978422007-11-01T17:18:00.000+05:302007-11-01T17:22:02.512+05:30Singleton design patternWhat is a singleton? It means nothing much than its word meaning. In c++ point of view Singleton means a class that can only have one object. So, A singleton class is a class that will have only one instance at any time.When to go for singleton? You must use a singleton pattern if your class must only have one instance. For example, * If your class is doing some loging to a console you Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com2tag:blogger.com,1999:blog-7599640639491014258.post-60701031194496135022007-10-31T18:47:00.000+05:302007-10-31T18:50:55.403+05:30What is a protected abstract virtual base pure virtual private destructor?A protected abstract virtual base pure virtual private destructor.This is one of the funny question and very less answered one. It may be a very long sentence. But the code needed for making a protected abstract virtual base pure virtual private destructor is quite simple.The below code is the one which makes a protected abstract virtual base pure virtual private destructorProgram:class BaseClassAmal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com22tag:blogger.com,1999:blog-7599640639491014258.post-83625520342065416172007-10-31T10:02:00.000+05:302007-10-31T10:06:32.535+05:30RapidMind - Stream programmingWhy RapidMind? RapidMind helps us to introduce data parallelism in our program. Data parallelism can optimize the program speed to a big extent. RapidMind gives data parallelism by using stream computing. Stream computing and Stream processors are nothing new to most of us right now. It helps us to execute some kernels(functions) on multiple data. Intel SSE, GPU etc are example of Stream Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0tag:blogger.com,1999:blog-7599640639491014258.post-68660629222832124632007-10-27T10:47:00.000+05:302007-10-27T11:59:11.046+05:30Performance analysis C++ vs C#Performance analysis C++ vs C#DescriptionC++ or C#, Which is the best language?This question have a clear answer if you are thinking in performance point of view. In the performance area C++ zigs where C# zags.Let us take a small example,Here I am doing some matrix operations using C++ and C#. Both are executing same algorithm.C++ Program int nRetCode = 0; const int nSize = 500; int* Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com5tag:blogger.com,1999:blog-7599640639491014258.post-65955232088950968972007-10-27T10:41:00.000+05:302007-10-27T10:44:26.743+05:30SIMD - Intel SSE( Streaming SIMD Extension )Intel SSE - Streaming SIMD ExtensionWhat is SSE? SSE is a an instruction set which has 4 series. SSE, SSE2, SSE3, SSE4. These instructions work on 128bit registers called XMM register. So the application can even grow 4 times faster. The instruction set can be downloaded from intel website directly. There are two different concepts in SSE which lets you read and write a block of data in memory.Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com14tag:blogger.com,1999:blog-7599640639491014258.post-41822256314256104162007-07-27T08:59:00.000+05:302007-07-27T09:05:59.171+05:30typedef name as identifier of constructor/destructorDescription: As per the C++98 a constructor declarator can be a typedef name if the declaration is inside class member specification. It must not be allowed if the declaration is done outside the class member specification. But the both GCC and VC++ differs in the behaviour. VC++ have correct implementation compared to gcc 3.4.2. Consider the following example,Example: class Alpha; typedef Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com3tag:blogger.com,1999:blog-7599640639491014258.post-9213322683765780342007-07-20T10:28:00.000+05:302007-07-20T10:42:53.909+05:30Calling a virtual function of a class from its constructor/destructorDescription: As you know the construction is done from base to derived and destruction just opposite you should avoid calling a virtual funciton from both constructor and destructor. When you call the virtual function from constructor the derived class is not yet constructed and if from destructor the derived class is already destructed. Hence compiler will make an arrangement so that the Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com1tag:blogger.com,1999:blog-7599640639491014258.post-52135034297283162092007-07-06T08:11:00.000+05:302007-07-06T08:13:55.327+05:30Making a class non derivable / Disabling Inheritability of a classDescription: Have you ever thought how to make a class non-derivable in C++? Your can do it by making use of the rule "The most derived class calls the constructor/destructor of virtual base class". At first to understand it we should analyze how we solved the diamond inheritance problem. For that we used the concept of virtual base class and inheriting the intermediate class virtuallyAmal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com98tag:blogger.com,1999:blog-7599640639491014258.post-7555071700045941122007-07-06T08:05:00.000+05:302007-07-06T08:08:29.695+05:30Microsoft VC++ 2005 Compiler Bug #2During a friend class specification the compiler is accepting a typedef name. ISOIEC14882-1998 section 9.1 point 5 states that a "typedef-name that names a class is a class-name, but shall not be used in an elaborated-type-specifier". Sections regarding typedef and friend also defines the same. So this usage must raise a compile time error. Instead the vc++2005 compiler accepts the program and Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com1tag:blogger.com,1999:blog-7599640639491014258.post-1142280694651413842007-07-06T07:15:00.000+05:302007-07-06T07:19:40.686+05:30Microsoft VC++ 2005 Compiler Bug #1It seems like there is implementation difference from ISOIEC14882-1998 rules regarding multiple inheritance and private access specifier.The private virtual base destructor is accessible from most derived class. No compile time error and no runtime error for program.class DisableDerive {public: DisableDerive(){ ; } private: ~DisableDerive(){ ; } friend class NonDerivable;};class Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com2tag:blogger.com,1999:blog-7599640639491014258.post-6469016430326099162007-07-06T06:12:00.001+05:302008-04-23T17:20:25.992+05:30Virtual destruction, delete() and delete[]Pre-Information
Q. Why base class destructor must be virtual?
A. A base class destructor must be virtual. The reason is if the derived class object is deleted using a base class pointer, the program will be ill-formed( Base class destructor may only be called ), if base class destructor is not virtual.
Tip:
The above rule will only make the program correct if we are NOT deleting the array of Amal Phttp://www.blogger.com/profile/06797355809736316660noreply@blogger.com0