Archive

Posts Tagged ‘embedded systems’

Compiler writing in the next decade

December 22nd, 2009 Derek-Jones 1 comment

What will be the big issues in compiler writing in the next decade? Compilers sit between languages and hardware, with the hardware side usually providing the economic incentive.

Before we set off to follow the money, what about the side that developers prefer to talk about. The last decade has not seen any convergence to a very small number of commonly used languages, if anything there seems to have been a divergence with more languages in widespread use. I will not attempt to predict whether there will be a new (in the sense of previously limited to a few research projects) concept that is widely integrated and used in many languages (i.e., the integrating of object oriented features into languages in the 90s).

Where is hardware going?

  • Moore’s law stops being followed. Moore’s law is an economic one that has a number of technical consequences (e.g., less power consumed and until recently increasing clock rates). Will the x86 architecture evolution dramatically slow down once processor manufacturers are no longer able to cram more transistors onto the same amount of chip real estate? Perhaps processor designers will start looking to compiler writers to suggest functionality that could be made use of by compilers to generate more optimal code. To date my experience of processor designers is that they look to Moore’s law to get a ‘free’ performance boost.

    There are a number of things a compiler code tell the processor, such as when a read or write to a cache line is the last one that will occur for a long time (enabling that line to be moved to the top of the reuse list).

  • Not plugged into the mains. When I made a living writing optimizers the only two optimizations choices were code size and performance. There are a surprising number of functional areas in which a compiler, given processor support, can potentially generate code that consumes less power. More on this issue in a later post.
  • More than one processor. Figuring out how to distribute a program across multiple, loosely coupled, processors remains a difficult research topic. If anybody ever comes up with a solution to this problem it might make more commercial sense for them to keep it secret, selling a compiling service rather than selling compilers.
  • Application Specific Instruction-set Processors. Most processors in embedded systems only ever run a single program. The idea of each program being executed on a processor optimized to its requirements sounds seductive. At the moment the economics are such that it is cheaper to take an existing, very low cost, processor and shoe-horn the application onto it. If the economics change the compiler used for each processor is likely to be automatically generated.

Enough of the hardware, this site is supposed to be about code:

  • New implementation techniques. These include GLR parsing and genetic algorithms to improve the generated code quality. The general availability of development machines containing more than 4G of memory will make it worthwhile for compiler writers to implement more whole program optimizations (which are currently being hemmed in by storage limits)
  • gcc will continue its rise to world domination. The main force at work here is not the quality of gcc but the disappearance of the competition. Compiler writing is not a big bucks business and compiler companies are regularly bought up by much larger hardware outfits looking to gain some edge. A few years go by, plans change, the compiler group are not making enough profit to warrant the time being spent on them by upper management and they are closed down. One less compiler vendor and a bunch of developers are forced to migrate to another compiler, which may or may not be gcc.
  • Figuring out what the developer meant to write based on what they actually wrote, and some mental model of software developers, is my own research interest. This is somewhat leading edge stuff, in other words nothing major has been achieved so far. Knowledge of developer intent looks like it will open the door to whole classes of new optimization techniques.

volatile handling sometimes overly volatile

March 2nd, 2009 Derek-Jones 1 comment

The contents of some storage locations, used by a program, might be modified outside of the control of that program, e.g., a real-time clock or the input port of a communications device. In some cases writing to particular storage locations has an external effect, e.g., a sequence of bits is sent down a communications channel. This kind of behavior commonly occurs in embedded systems

C and C++ support the existence of variables that have been mapped to such storage locations through the use of the volatile type qualifier.

volatile long flag;
volatile time_t timer;
 
struct {
                    int f1 : 2;
          volatile int f2 : 2;
                    int f3 : 3;
         } x;

When a variable is declared using volatile compilers must assume that its value can change in ways unknown to the compiler and that storing values into such a variable can have external effects. Consequently almost all optimizations involving such variables are off limits. Idioms such as timer = timer; are used to reset or refresh timers and are not dead code.

Volatile is a bit of an inconvenience for writers of code optimizers, requiring them to add checks to make sure the expression or statement they want to attempt to optimize does not contain a volatile qualified variable. In many environments the semantics of volatile are not applicable, which means that bugs in optimizers have a much smaller chance of being detected than faults in other language constructs.

There have been a number of research projects investigating the use of the const qualifier, but as far as I know only one that has investigated volatile. The ‘volatile’ project found that all of the compilers tested generated incorrect code for some of the tests. License agreements prevented the researchers giving details for some compilers. One interesting observation for gcc was that the number of volatile related faults increased with successive compiler releases; it looks like additional optimizations were being implemented and these were not checking for variables being volatile qualified.

One practical output from the project was a compiler stress tester targeting volatile qualified variables. The code generated by stress testers often causes compilers to crash and hang and the researchers reported the same experience with this tool.

There is one sentence in the C Standard whose overly broad wording is sometimes a source of uncertainty: What constitutes an access to an object that has volatile-qualified type is implementation-defined. This sentence applies in two cases: datatypes containing lots of bytes and bit-fields.

To save space/money/time/power some processors access storage a byte, or half-word, at a time. This means that, for instance, an access to a 32-bit storage location may occur as two separate 16-bit operations; from the volatile perspective does that constitute two accesses?

Most processors do not contain instructions capable of loading/storing a specified sequence of bits from a byte. This means that accesses to bit-fields involve one or more bytes being loaded and the appropriate bits extracted. In the definition of x above an access to field f1 is likely to result in field f2 (and f3) being accessed; from the volatile perspective does that constitute two accesses?

Unfortunately it is very difficult to obtain large quantities of source code for programs aimed at the embedded systems market. This means that it is not possible to obtain reliable information on common usage patterns of volatile variables. If anybody knows of any such code base please let me know.

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com generic propecia effective

buy fast propecia

buy viagra mexico

mail online order propecia

buy propecia in the uk

order viagra or levitra

ganeric cialis

female viagra pills

obtain viagra without prescription

order cheap levitra

get cialis

online generic cialis 100 mg

canadian pharmacy viagra

cost of daily cialis

canada online pharmacy levitra

how much cialis

generic levitra overnight delivery

buy cialis once daily

cheap propecia 5mg

cialis delivered overnight

online pharmacy propecia renova

canadian drugs propecia

buy viagra germany canadian meds

cialis by mail

canada levitra

generic cialis sale

buy cheap generic propecia

generic viagra made in usa

cheapest prices for viagra

buy generic viagra india rx

canada viagra generic

name brand cialis

discount drug propecia

cialis 20 mg

levitra canadian

cheap order prescription propecia

canada viagra pharmacies scam

order prescription propecia

bio viagra herbal

cheap viagra from uk

low price levitra

i need to buy propecia

how much to buy viagra in pounds

online propecia prescription

cialis daily

how to get viagra

best way to use cialis

natural viagra

best price generic propecia

buy cialis without prescription

generic propecia sale

levitra prescription

discount cialis india

cheapest viagra online

generic propecia fda approved

levitra cost

generic cialis from india

buy cialis in usa

buy generic levitra

buy viagra china

cost of viagra

online cialis

buy generic propecia

canada cheap propecia

cheap cialis from india

generic propecia for sale

cialis prescription

cialis profesional

cialis next day delivery

drug generic propecia

cialis online

levitra in india

discount levitra rx

cheap fast levitra

lowest propecia 1 mg

canada online pharmacy propecia

generic propecia 5mg

gele viagra

levitra buy online

how to buy cialis in canada

online propecia uk

levitra from canadian pharmacy

buy cheap levitra

how much does cialis cost

discount levitra purchase

buy real viagra online

buy cialis fedex shipping

cialis from canada

cialis 100 mg generic

canadian healthcare viagra

cialis uk

cialis quick shipment

levitra tabs

cialis price

buying generic propecia

cialis price 100 mg

levitra where to buy

overnight delivery cialis

canadian propecia rx

buying online propecia

buy cialis canada

buy levitra online from canada

best viagra

lowest propecia prices in canada

cheap levitra prescription

get levitra online

canadian viagra and healthcare

cheapest viagra

cialis buy overnight

lowest cost levitra

get cialis online

best price cialis

once daily cialis

cialis professional 100 mg

buy generic cialis

buy propecia now

herbal propecia

cialis overnight delivery

buy propecia online

brand viagra over the net

get propecia online pharmacy

cialis daily in canada

cheap cialis

cialis transdermal

buy cialis 5 mg

indian viagra

buying viagra in canada

bestellen levitra online

cialis vs levitra

levitra next day delivery

brand cialis for sale

best price for generic cialis

how much is viagra

cheapest propecia sale uk

levitra sales uk

lowest price levitra

daily dosage cialis

discount propecia propecia

cheap levitra tablets

generic propecia alternative

canadian pharmacies cialis

cialis for woman

generic levitra online

low cost levitra

indian generic levitra

cialis professional no prescription

buy cheap generic levitra

cialis price in canada

buy 5 mg cialis

buy propecia generic

generic viagra made in india

buy propecia prescriptions online

cialis strenght mg

lowest propecia prices

cialis to buy

online propecia prescriptions

buy cialis usa

cialis on women

mail order propecia

buy levitra vardenafil

buying cialis next day delivery

buy cialis online uk

cheapest overnight cialis

cialis cheap us pharmacy

5 mg original brand cialis

online levitra

canadian viagra

cheap viagra online

buy viagra online cheap us

cialis in mexico

canadian online pharmacy cialis

buy viagra without prescription

cialis 5 mg

cialis 5 mg italia

low cost canadian viagra

canada propecia prescription

levitra now online

cialis and canada custom

levitra online

cialis woman

cialis 100 mg

buying propecia

cialis no prescription

canadian pharmacy

cheapest price propecia cheap

low cost propecia

buy real cialis

cheap propecia no prescription

can i get viagra in mexico

ordering propecia online

levitra 10mg

lowest price propecia

cialis headaches

canadian pharmacy discount code viagra

buy discount viagra

cheap cialis soft

generic levitra vardenafil

online viagra gel to buy

mexico levitra

canadian pharmacy cialis

lowest price on non generic levitra

get levitra

cheap levitra uk

levitra online no prescription

buy levitra online no prescription

cialis pharmacy

levitra for sale

cost levitra low

canadian healthcare

discount propecia online

buy prescription propecia without

healthcare canadian pharmacy

order cheapest propecia online

generic viagra canada

cialis professional 20 mg

levitra online us

buy propecia where

online pharmacy propecia viagra

combine cialis and levitra

cialis one a day

buy canada levitra

generic cialis next day shipping

buy propecia online pharmacy

buying cialis

buy now propecia

buy viagra on line

cheapest propecia prescription

discount us propecia

order propecia

does generic cialis work

lowest priced propecia

ordering cialis gel

cheapest viagra usa

levitra viagra online

buy dosages levitra

order generic levitra

levitra low price

cialis fast delivery usa

lowest price propecia best

buy levitra us

cialis overnight

discount generic propecia

buy cialis cannada

levitra viagra cialis

discount propecia rx

indian cialis generic

buying propecia online

cialis discounts

online ordering propecia

brand name cialis

cialis tablets

generic viagra 100 mg

cialis and diarrhea

lowest price for propecia

cialis next day

buy viagra

cheap viagra canada or india

buy levitra overnight

order cheap propecia

buy levitra online viagra

cialis and ketoconazole

levitra discount

getting cialis from canada

cheap propecia online prescription

cheap levitra

order levitra online

online cheap viagra

cialis purchase

info levitra

levitra mg

buy propecia without prescription

cheap prescription propecia

for sale levitra

levitra in canada

next day viagra

cheap discount levitra

generic viagra canadian

china viagra

buy can from i propecia who

cialis from mexico

mexico pharmacy cialis

cialis 5 mg buy

buy cialis online canada

buy propecia online from usa pharmacy

buy cheap levitra online

indian cialis

levitra pill

5 mg daily cialis

generic levitra canada

generic levitra cheap

buy propecia online prescription

levitra cheap fast

levitra mail order

buy branded viagra

genuine cialis pills

buy propecia on line

buying levitra online

buy cialis for daily use

hydrochlorothiazide cialis

canada meds viagra