Monday, June 2, 2014

Re: Look

Re: Look

Monday, August 8, 2011

Neat explanation of Hyperthreading concept

I came about an neat, brief explanation of Hyperthreading in the Apple MacBook Air review here (host: arstechnica.com) by Iljitsch van Beijnum

Hyperthreading

Twenty years ago, CPUs were nice and simple. They executed instructions that were read from memory one at a time. Life was good, but not particularly fast. Then CPUs became superscalar and started executing more than one instruction at a time. (See this classic piece from Ars cofounder Jon Stokes for background.)

It's easier to do multiple things in parallel than to do one thing faster, which is also why today's CPUs have multiple cores. Each core is basically a fully formed CPU of its own, although both CPU cores still have to share a single connection to the outside world. But as long as memory bandwidth isn't an issue, each CPU core can run at full speed regardless of what the other(s) are doing. So as long as the software manages to split up the work that must be done into pieces that can be executed fairly independently by different cores, having multiple cores pretty much always improves performance.

This is not exactly the case with hyperthreading. To the software, a CPU like the i5 or i7, which has two cores that can each run two (hyper)threads, looks the same as a four-core CPU. But in reality, there's only two cores worth of execution units that do the actual work. What the hyperthreading does is feed the execution units instructions from two different software threads, so that if one thread doesn't use the full capacity of the CPU core at a given point, the execution units are kept busy with instructions from the other thread.

It's a bit like a print shop with several printers. Let's say there are two black-and-white printers and one color printer. A computer analyzes PDF files that need to be printed 20 pages or so at a time, and sends the color pages to the color printer and the black-and-white pages to the two other printers. Having multiple cores is like setting up another computer and another three printers. That's going to double the output—if the guy that has to fill up the paper trays can keep up—but it doesn't improve efficiency. If there's 50 pages of color followed by 50 pages of black text, that still means that at any given point, at least one printer is doing nothing.

By adding a second computer, but no extra printers, it's possible to process two PDF files at the same time, so maybe while one computer is sending only color pages, the other is sending black-and-white pages. In that case you get double the performance without doubling the number of execution units. But in practice, the gain is much smaller because the needs of the multiple threads will overlap a good deal.

Unfortunately, there doesn't seem to be any way to turn off hyperthreading to see how well the system performs with and without it. So instead, I ran an old command line based, single threaded benchmark:NBench. First I ran one copy of the program, then two at the same time, and then four. In a normal dual core system, you'd expect code that isn't limited by memory bandwidth to run at the same speed speed regardless of whether there's another copy of the same code also running on the other core. However, the Core i5 and i7 CPUs have a feature called Turbo Boost. If only one core is active, this core gets to run faster than normal, keeping the overall heat output of the CPU within normal limits. Actually, the 1.8GHz Core i7 in the MacBook Air gets to run faster than advertised all the time.

If you look at the kernel.log file in /var/log, you'll see this cryptic message:

AppleIntelCPUPowerManagement: Turbo Ratios 008B

This means if four CPU cores are running, the extra speed is 0. The same if three cores are running. With two active cores the extra speed is 8, and with only one core active, it's B (which means 11). The extra speed is added in steps of 100MHz. Our ultra low voltage (ULV) Core i7 being a dual core CPU, there are never any third or fourth cores active, so we always get 800MHz of extra CPU power. So this is really a 2.6GHz CPU, with Intel being surprisingly modest in its marketing. If only one CPU core is active, the clock speed is increased to 2.9GHz.

Back to our testing. NBench runs ten different tests. With one copy of the program running all by itself, the extra clock cycles made the different tests between 10 and 19 percent faster compared to the results where a second copy of the program was running at the same time. It looks like the penalty for not being multithreaded isn't as severe as it was on previous multicore architectures.

I then ran four copies of the benchmark at the same time. Hyperthreading helped a lot here; four copies of the program were able to execute between 20 and 55 percent more iterations per second compared to two copies.

Hyperthreading problems

This is not the whole story, however. Let's go back to our print shop: what if the two print jobs use completely different fonts? Worst case is that the printer can't keep all the necessary fonts in memory, so each time it gets a page from the other print job, it has to load new fonts into memory, kicking out the previously loaded fonts. Now, printing two jobs at the same time is actually slower than printing them one at a time. Hyperthreading can lead to worse performance than just using one thread per core if the different threads need to access different parts of RAM, leading to cache thrashing.

For this reason, many people turned off hyperthreading in the past, but it looks like Intel's current implementation is robust enough that it helps most of the time. Because the CPU can keep track of four different threads of execution in hardware, the software no longer has to perform as many heavy handed "context switches" between different processes that need CPU time, making overall system efficiency and responsiveness better. You may want to limit the number of concurrent threads such a hyperthreading-hostile application uses, though.

Saturday, June 11, 2011

Hans Rosling – Making hard lesson fun

Hans Rosling - TED _ Washing Machines

Saturday, May 28, 2011

hi

 


hey
   I recently found a very good site:<< www.google-elec.com >>It can offer you so many kinds of electronic products which you may be in need,such as- laptops, -gps, -TV, -cell phones, -ps, -MP3/4, -motorcycles even several kinds of musical instruments and etc..
  its quality is very good. And the website is promoting their products these days, so they have very good price and big discount now.  The promotion will keep 30 days .
I hope you have a good shopping mood!
Greetings!

 

Thursday, April 28, 2011

Perl code to print out differences between 2 files


The following perl code was written to find the differences between 2 files and to print it out. It will print out lines that are in first file but not in second.

Monday, September 6, 2010

Default seed of VCS can

In system verilog,if a packet class is created with rand items and every independent run with vcs generates the same values for rand items.

image

 

The above code having three 2-bit rand variables, when run with vcs command:

> vcs –sverilog –R test.sv

will output same value a=2, b=2, c=1 for all 10 iterations even when run again with the same above command. This is because, every vcs executes the test always with the default seed, which is equal to 1. And hence, randomize() function will always execute for constant seed (=1) in this process.

Utilizing the characteristics of rand type, the above code can be modified to dump different values of a, b, c in each iteration when run with the vcs command.

image

This will dump out unique values of a, b and c in each iteration.

The same can be run by changing RNG value for seeding from the command line using +ntb_random_seed. For running regression this is the best solution.

Friday, August 20, 2010

fork…join_none and for loop

An interesting case with fork…join_none block defined inside a for loop in system verilog is shown here as an example:

image

 

The intended result of this code is to display the iteration count value, i, from 0 to 3. That is, each call to system task, $display, will hold a unique value of i.

But the output of the above example is:

image

This can be explained as: Each iteration in the for loop initiates a parallel thread to display the value of variable i (iteration count). Because of join_none keyword, none of the threads (blocks) are waited for completion of their execution. So the immediately next statement after the for loop (zero time delay) is executed, which in this case is $display (“THE END”) system task and hence is the first line of output observed.

By the end of execution of for loop (zero time), the value of i is 4. This is the value that gets updated across all the threads (blocks) that has been initiated to display the value of i. Even before the threads begin to start executing the value of i has been changed to 4, which is what is observed in the output. This result implies that variable i is a static variable.

For this particular example replacing join_none by join statement will result into the expected output. That is, each parallel thread will display unique value of i and the output seen is i changing in consecutive order from 0 to 3.

In case join_none statement cannot be replaced because, say for example, of time consuming user defined task being called and the logic requires that no time is to be spent before executing the next statement following the for loop, then create an automatic variable inside a for loop and assign i to it before starting the fork…join_none block.

image

Here, keyword automatic can be ignored as well. Variable k is roughly similar to C automatic variable. Now, the lifetime of automatic variable k is the lifetime of each fork...join_none block. So each block will have a unique value of k, which doesn’t get changed even after completion of for loop. 

image

Wednesday, March 3, 2010

Part Select or Slice implementation in SV

To optimize the following system verilog code:

sample[0] = &dq[7:0];

sample[1] = &dq[15:8];

sample[2] = &dq[23:16];

sample[3] = &dq[31:24];

...

so on for 64-bit packed array dq. This was simplified by using for loop with system verilog slice or part select of packed arrays as:

for (int i=0,j=0; i<ST_W; i+=8, j++) begin //ST_W=DATA_WIDTH/16

sample[j] = &dq[i+:8];

end

The index i represents position of the slicing which is added to a constant 8 to determine the size of part select or slice. Thus, the code can be reused for any data width with reduced code density and easy readability.

Saturday, November 14, 2009

GVIM syntax highlight for systemverilog

Gvim syntax file for SystemVerilog & AVM can be downloaded from the following link: http://www.sibridgetech.com/download/systemverilog_avm.zip  

For gvim (portable) installed on windows, the following steps need to be followed:

1. The unzipped file needs to saved in ...\GVimPortable\App\vim\vim71\syntax directory.
2. Then, edit the file ..\GVimPortable\App\vim\vim71\filetype.vim to add the following lines (search line containing "verilog" in the file and insert the below lines beneath it):

" System Verilog
au BufNewFile,BufRead *.sv,*.svh setf systemverilog_avm

3. Close and open any systemverilog file having .sv and/or .svh extension.


Friday, November 13, 2009

TLM in OVM

Here's a very good demonstration of the need and importance of TLM in OVM.

Wednesday, September 16, 2009

ಅತ್ತು ಅತ್ತು ಮತ್ತತ್ತು

ಯಕ್ಷನ ವಿರಹದಿ೦ದ ಬೆ೦ದ ಯಕ್ಷಿಯ ಚಿತ್ರ - ಬೇ೦ದ್ರೆಯವರ ದೃಷ್ಟಿಯಲಿ  :

ಅತ್ತು ಅತ್ತು ಮತ್ತತ್ತು ಕೆದರಿಕೊ೦ಡಿಹುದು ಕಣ್ಣ ಪೊಗರು
ಬೆಚ್ಚನುಸಿರನು೦ಡು೦ಡು ಸೊಪ್ಪೆಯಾಗಿಹುದು ತುಟಿಯ ಚಿಗುರು
ಗಲ್ಲದಲ್ಲಿ ಕೈ, ಓರೆ ಮೋರೆ, ನಿಡಿಗೂದಳುದ್ದ  ಚಿ೦ತೆ
ಮೋಡ ಮುಸಕಲಿರೆ ಮ೦ಕುಕವಿದ ಆ ದೀನ ಚ೦ದ್ರನ೦ತೆ II

Monday, July 27, 2009

Best poll question ever


Best poll question I've come across (Adult Discretion Advised), which beats even the daily polls by Sagarika "faze the nation" Ghose on CNN-IBN.

Note (DON'T SAY I DIDN'T WARN):
The first link leads to "Adult Discretion Advised" kind of site, so please follow the advise, especially when you are in office. 

Wednesday, March 18, 2009

Life is Just is

Like a small stone wading thru the water to the depth -- half resisting but willing, half willing but resisting -- all the while following the natural laws, I've let myself go thru new phase of life. I only fulfill the natural laws of life without questioning and without seeking for answers.

Life is neither a question nor an answer to an unknown question. It is just is.

Tuesday, March 3, 2009

Terrorism LeT loose

Few good articles analysing today's heinous act by Pakistan terrorists:

1. Prem Panicker's take on today's terrorist attack on SL cricketers:
http://www.rediff.com/cricket/2009/mar//03prem-panicker-sri-lanka-team-attacked-in-pakistan.htm

2. B.Raman, India's best defence analyst, hints that this attack might be ordered by LTTE and executed by fringe terrorist-group in Pakistan.
http://ramansterrorismanalysis.blogspot.com/2009/03/hum-repays-old-debt-to-ltte-in-lahore.html

All this after Imran Khan had given strong/personal assurance to India about terrorists not attacking any cricketers if they tour Pakistan.

Saturday, February 7, 2009

Memento


--------------------------------------------------
Natalie: ... Even if you get your revenge, you are not gonna remember it, you are not even gonna know that it happened.
Lenny: My wife deserves a vengeance. It doesn't make any difference whether I know about it. Just because there are things that I don't remember, doesn't make my actions are meaningless. The world just doesn't disappear when  you close your eyes, does it? Anyway, maybe I'll take a photograph...

In movie 'Don', zeenat Aman in old/Priyanka Chopra in new, have opposite view on a similar situation. They want Don to recover back his memory before they can have their revenge. They reason it as saying Don should know why exactly he is being killed and also who (she is a sister of one of Don's victim) is killing him. 

--------------------------------------------------


Teddy: You can't trust a man's life to your little notes and pictures
Lenny: Why not?
Teddy: Because, Your notes could be unreliable
Lenny: memories are unreliable
Teddy: Ah... Please...
Lenny: No No No...really. Memories aren't just perfect. They are not even that good. Ask the Police. Eyewitness testimonies are unreliable. Cops don't catch the thieves by sitting around and remembering stuff, right?... They collect facts, they make notes and they draw conclusions. Facts, not memories. That's how you investigate.
Teddy: I know. That's what I used to do.
Lenny: Look, memories can change the shape of the room, it can change the color of a car, and memories can be distorted. They are just an interpretation, they are not a record. And they are irrelevant if you have the facts.


Friday, February 6, 2009

e2sv and the shining

To migrate from 'e' based verification environment to sytem verilog is the possible biggest trend in the coming days. Especially during and immediately after the recession days. So any work done in automating or semi-automating the translation from e to SV could reap benefits.

Beginning from here, let me see how much can I contribute. It is a scary project, but could it be any scarier than this classic horror movie.

youtube link to one of finely crafted scene by Stanley Kubrick and wonderfully enacted by Jack Nicholson

 

Tuesday, January 27, 2009

Filters: Recalling the basics

Filters: Recalling the basics

The following points on filters can only help to recall some of the basics and might provide the direction for further study. This is not a coherently written article but only a brief collection of interesting points that would explain filters in general.

To start with...

Analogue filters provide the required filtering using op-amps, capacitors etc and Digital filters uses a digital processors chip (like DSP)

In digital filters, an analog input is ADCed (sampled and quantized/digitized), then this is input to a processor, which perform some calculation on this input like xn+xn-1 or xn + yn-1, where x is input & y is output. The (filtered) result is then fed to DACs which convert them back to analog form.

Calculation inside a processor define a filter

If output is directly dependent on present and/or previous inputs, then this is called non-recursive filter or FIR

If output is dependent not only input values but also on previous outputs, then this is called recursive filter or IIR.

IIR - theoretically produces an infinite response to an impulse input (value 1 at time 0.) Practically, the output fades to 0 after a finite period!

FIR - Produces a response for finite period for the same impulse input

From the definitions it appears that IIR (recursive) filters require more calculation than IIR? No, actually FIR requires more calculation (less order filters) than IIR fitlers to achieve the same freq response characteristics Eg of recursive filter: y0 = x0 + y-1 y1 = x1 + y0 y2 = x2 + y1 and so on.

So, y9 = x9 + y8 for IIR calculation but for non-recursive, y9= x0+x1+x2+x3+x4+x5+x6+x7+x8+x9 (all prev inputs should be saved in memory.) Thus FIR requires more calc than IIR.

For IIR, order is the number of largest previous input or previous output. yn = xn + yn-1 is first order eg. yn = xn-1 + xn-2 +yn-1 +yn-2 is second order eg Ex of zero order IIR filter?? Impossible becoz yn = xn (is not FIR) and yn = yn is linear device and not a kind of filter by any definition.

Transfer function: Puts the filter expression in compact convenient form (op/ip) From this we can derive many characteristics of a filter like freq response. so yn = xn + yn-1 can be represented as

	yn = xn + z^-1yn   (1-z^-1)yn = xn   TF = yn/xn = 1/(1-z^-1) of IIR filter 

For FIR, TF doesn't contain any denominator. eg. yn = a0 + a1z^-1+ a2z^-2  

Tuesday, January 13, 2009

Origins of Urdu

Interesting history of origins of Urdu

Starting with Mahmud of Ghazni (971-1030AD), Urdu grew to lay its roots in the North West and Central India. It evolved over the last two centuries and soon became a base for poetry in the North of India and Pakistan. The mogul courts used basically two languages, Persian or Farsi and the religious language which was Arabic. The sultans themselves spoke Turkish (or a Turkic variant). Urdu or Ordu means tent or army and Urduca was thus the language of the army. This 'Lashkarai Zaban' or Zaban e Ordu was needed for the armies of India, armies that often comprised soldiers with various native mother tongues from diverse regions of the Middle East & India. Hence, Urdu evolved to become the chosen language to address these soldiers as it abridged several base languages

Friday, January 2, 2009

Doordarshan nostalgia

If you are nostalgic about old doordarshan TV serials, then this should make you even more so: 

http://in.youtube.com/watch?v=eA09SmFFOZ0

Remember "Bharat Ek Khoj"? Where a person enacting as Jawaharlal Nehru (also seen in movie 'Gandhi'),  use to narrate us the history of India from start ? Then, you might find this more educative now watching it again. Especially, the opening credits, which I realized now, has the words from the creation verses  of Rig Veda. 


Terrorists from across the border must be shown this serial before they blow up our country and make a movie of their own to show it to their children as titled: "Khoj: Ek Bharat ki" and in English: "LeTs Discover India"


Powered By Blogger